fix auth read

This commit is contained in:
veclavtlica
2026-10-07 12:05:28 +03:00
parent 1e200cc7f2
commit e7abe1a1d2
3 changed files with 15 additions and 11 deletions
+2 -2
View File
@@ -39,8 +39,8 @@ typedef struct com_buf {
p_v->flags = p_f | COM_BUF_STACK; \ p_v->flags = p_f | COM_BUF_STACK; \
p_v->typesz = sizeof(p_t); p_v->typesz = sizeof(p_t);
#define com_buf_index(p_t, p_v, p_i) \ #define com_buf_index_as(p_t, p_v, p_i) \
(p_t *)(&(p_v)->data[(p_v)->typesz * (p_i)]) (p_t *)(&(p_v)->data[sizeof(p_t) * (p_i)])
/* Dynamic allocation to persist no matter the function flow. */ /* Dynamic allocation to persist no matter the function flow. */
struct com_buf *com_buf_make(uint32_t cap, uint32_t flags); struct com_buf *com_buf_make(uint32_t cap, uint32_t flags);
+4 -4
View File
@@ -24,7 +24,7 @@
bool quited = false; bool quited = false;
bool fileread(void *ctx, char *into, uint32_t bytes) { bool fileread(void *ctx, char *into, uint32_t bytes) {
return com_std_syscall(0, (intptr_t)ctx, (intptr_t)into, bytes); return com_std_syscall(0, (intptr_t)ctx, (intptr_t)into, bytes) == bytes;
} }
bool fileskip(void *ctx, uint32_t bytes) { bool fileskip(void *ctx, uint32_t bytes) {
@@ -63,11 +63,11 @@ static struct plr_x11_auth_entry {
if (!com_bin_read_u16(b, &data_len)) if (!com_bin_read_u16(b, &data_len))
goto BREAK; goto BREAK;
uint32_t data_idx; uint32_t data_idx;
if (!com_bin_read_bufbi(b, buf, &data_idx, name_len)) if (!com_bin_read_bufbi(b, buf, &data_idx, data_len))
goto BREAK; goto BREAK;
result.auth_name = com_buf_index(struct com_buf, buf, name_idx); result.auth_name = com_buf_index_as(struct com_buf, buf, name_idx);
result.auth_data = com_buf_index(struct com_buf, buf, data_idx); result.auth_data = com_buf_index_as(struct com_buf, buf, data_idx);
result.success = true; result.success = true;
return result; return result;
BREAK: BREAK:
+9 -5
View File
@@ -1,6 +1,7 @@
CC = clang CC = clang
RELEASE ?= 0 RELEASE ?= 0 # Optimize.
SQUEEZE ?= 0 DEBUG ?= 1 # Emit debug info.
SQUEEZE ?= 0 # Nuclear option to save space.
BITS ?= 64 BITS ?= 64
CFLAGS = -Wall -std=gnu99 -flto=thin -ffast-math -fno-ident -fvisibility=hidden CFLAGS = -Wall -std=gnu99 -flto=thin -ffast-math -fno-ident -fvisibility=hidden
ifeq ($(MAKECMDGOALS),linux) ifeq ($(MAKECMDGOALS),linux)
@@ -23,10 +24,13 @@ ifeq ($(MAKECMDGOALS),wasm)
CFLAGS += -Wl,--compress-relocations CFLAGS += -Wl,--compress-relocations
endif endif
endif endif
ifeq ($(RELEASE), 0) ifeq ($(DEBUG), 1)
CFLAGS += -g3 -O1 CFLAGS += -g3
else else
CFLAGS += -Wl,--strip-all -DNDEBUG -O3 -fuse-ld=lld -fmerge-all-constants -Wl,-O3 \ CFLAGS += -DNDEBUG -Wl,--strip-all
endif
ifeq ($(RELEASE), 1)
CFLAGS += -O1 -fuse-ld=lld -fmerge-all-constants -Wl,-O3 \
-ffunction-sections -fdata-sections -Wl,--gc-sections \ -ffunction-sections -fdata-sections -Wl,--gc-sections \
-Wl,-mllvm,--vectorize-slp=true \ -Wl,-mllvm,--vectorize-slp=true \
-Wl,-mllvm,--enable-gvn-hoist=true -Wl,-mllvm,--enable-gvn-hoist=true