Skip to content

Commit

Permalink
Revert "maybe fix, at least doesn't crash"
Browse files Browse the repository at this point in the history
  • Loading branch information
andywolk committed Jan 9, 2024
1 parent f1af4fa commit 432a757
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/kws.c
Original file line number Diff line number Diff line change
Expand Up @@ -1432,12 +1432,14 @@ KS_DECLARE(ks_ssize_t) kws_read_frame(kws_t *kws, kws_opcode_t *oc, uint8_t **da
blen = (int)(kws->body - kws->bbuffer);

/* The bbuffer for the body of the message should always be 1 larger than the total size (for null term) */
/* Check if existing buffer size is big enough already */
if (need + blen > (ks_ssize_t)kws->bbuflen) {
if (blen + kws->plen >= (ks_ssize_t)kws->bbuflen) {
void *tmp;

/* Increase allocated buffer size by difference needed including extra NULL byte */
kws->bbuflen += need + 1;
/* must be a sum of the size already written to the body (blen) plus the size to be written (kws->plen) */
kws->bbuflen = blen + kws->plen; /* total size */

/* and 1 more for NULL term */
kws->bbuflen++;

if (kws->payload_size_max && kws->bbuflen > kws->payload_size_max) {
/* size limit */
Expand Down

0 comments on commit 432a757

Please sign in to comment.