Skip to content

Commit

Permalink
[BUGFIX] uses lsxpack_offset_t type cast for name_offset and val_offset.
Browse files Browse the repository at this point in the history
  • Loading branch information
gwanglst committed May 18, 2023
1 parent ac3f635 commit 19863c2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
12 changes: 6 additions & 6 deletions lsqpack.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions lsxpack_header.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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
Expand Down

0 comments on commit 19863c2

Please sign in to comment.