From 19863c2ed8bf28d648213460093d1991def4e643 Mon Sep 17 00:00:00 2001 From: George Wang Date: Wed, 17 May 2023 22:59:56 -0400 Subject: [PATCH] [BUGFIX] uses lsxpack_offset_t type cast for name_offset and val_offset. --- lsqpack.c | 12 ++++++------ lsxpack_header.h | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lsqpack.c b/lsqpack.c index 8f919af..d523fd2 100644 --- a/lsqpack.c +++ b/lsqpack.c @@ -3004,7 +3004,7 @@ header_out_static_entry (struct lsqpack_dec *dec, memcpy(dst, ": ", 2); dst += 2; } - xhdr->val_offset = (lsxpack_strlen_t)(dst - xhdr->buf); + xhdr->val_offset = (lsxpack_offset_t)(dst - xhdr->buf); memcpy(dst, static_table[ idx ].val, static_table[ idx ].val_len); dst += static_table[ idx ].val_len; if (http1x) @@ -3065,7 +3065,7 @@ header_out_dynamic_entry (struct lsqpack_dec *dec, memcpy(dst, ": ", 2); dst += 2; } - xhdr->val_offset = (lsxpack_strlen_t)(dst - xhdr->buf); + xhdr->val_offset = (lsxpack_offset_t)(dst - xhdr->buf); memcpy(dst, DTE_VALUE(entry), entry->dte_val_len); dst += entry->dte_val_len; if (http1x) @@ -3112,7 +3112,7 @@ header_out_begin_static_nameref (struct lsqpack_dec *dec, memcpy(dst, ": ", 2); dst += 2; } - xhdr->val_offset = (lsxpack_strlen_t)(dst - xhdr->buf); + xhdr->val_offset = (lsxpack_offset_t)(dst - xhdr->buf); read_ctx->hbrc_out.state = XOUT_VALUE; read_ctx->hbrc_out.off = 0; return 0; @@ -3160,7 +3160,7 @@ header_out_begin_dynamic_nameref (struct lsqpack_dec *dec, memcpy(dst, ": ", 2); dst += 2; } - xhdr->val_offset = (lsxpack_strlen_t)(dst - xhdr->buf); + xhdr->val_offset = (lsxpack_offset_t)(dst - xhdr->buf); read_ctx->hbrc_out.state = XOUT_VALUE; read_ctx->hbrc_out.off = 0; return 0; @@ -3215,10 +3215,10 @@ header_out_write_name (struct lsqpack_dec *dec, } memcpy(xhdr->buf + xhdr->name_offset + read_ctx->hbrc_out.off, ": ", 2); - xhdr->val_offset = (lsxpack_strlen_t)(xhdr->name_offset + read_ctx->hbrc_out.off + 2); + xhdr->val_offset = (lsxpack_offset_t)(xhdr->name_offset + read_ctx->hbrc_out.off + 2); } else - xhdr->val_offset = (lsxpack_strlen_t)(xhdr->name_offset + read_ctx->hbrc_out.off); + xhdr->val_offset = (lsxpack_offset_t)(xhdr->name_offset + read_ctx->hbrc_out.off); xhdr->name_len = (lsxpack_strlen_t)read_ctx->hbrc_out.off; read_ctx->hbrc_out.state = XOUT_VALUE; read_ctx->hbrc_out.off = 0; diff --git a/lsxpack_header.h b/lsxpack_header.h index 88ddbae..bb29be8 100644 --- a/lsxpack_header.h +++ b/lsxpack_header.h @@ -99,11 +99,11 @@ lsxpack_header_set_offset(lsxpack_header_t *hdr, const char *buf, { memset(hdr, 0, sizeof(*hdr)); hdr->buf = (char *)buf; - hdr->name_offset = (lsxpack_strlen_t)name_offset; + hdr->name_offset = (lsxpack_offset_t)name_offset; assert(name_len <= LSXPACK_MAX_STRLEN); hdr->name_len = (lsxpack_strlen_t)name_len; assert(name_offset + name_len + 2 <= LSXPACK_MAX_STRLEN); - hdr->val_offset = (lsxpack_strlen_t)(name_offset + name_len + 2); + hdr->val_offset = (lsxpack_offset_t)(name_offset + name_len + 2); assert(val_len <= LSXPACK_MAX_STRLEN); hdr->val_len = (lsxpack_strlen_t)val_len; } @@ -116,11 +116,11 @@ lsxpack_header_set_offset2(lsxpack_header_t *hdr, const char *buf, { memset(hdr, 0, sizeof(*hdr)); hdr->buf = (char *)buf; - hdr->name_offset = (lsxpack_strlen_t)name_offset; + hdr->name_offset = (lsxpack_offset_t)name_offset; assert(name_len <= LSXPACK_MAX_STRLEN); hdr->name_len = (lsxpack_strlen_t)name_len; assert(val_offset <= LSXPACK_MAX_STRLEN); - hdr->val_offset = (lsxpack_strlen_t)val_offset; + hdr->val_offset = (lsxpack_offset_t)val_offset; assert(val_len <= LSXPACK_MAX_STRLEN); hdr->val_len = (lsxpack_strlen_t)val_len; } @@ -133,7 +133,7 @@ lsxpack_header_prepare_decode(lsxpack_header_t *hdr, memset(hdr, 0, sizeof(*hdr)); hdr->buf = out; assert(offset <= LSXPACK_MAX_STRLEN); - hdr->name_offset = (lsxpack_strlen_t)offset; + hdr->name_offset = (lsxpack_offset_t)offset; if (len > LSXPACK_MAX_STRLEN) hdr->val_len = LSXPACK_MAX_STRLEN; else