Skip to content

Commit

Permalink
lepc: added bound check for collect_tgt
Browse files Browse the repository at this point in the history
  • Loading branch information
iwashiira authored and lws-team committed May 30, 2024
1 parent d1d622d commit 090ec8e
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions lib/misc/lecp.c
Original file line number Diff line number Diff line change
Expand Up @@ -673,10 +673,21 @@ lecp_parse(struct lecp_ctx *ctx, const uint8_t *cbor, size_t len)
* We're collecting int / float pieces
*/
case LECP_COLLECT:
if (ctx->be)
*ctx->collect_tgt++ = c;
else
*ctx->collect_tgt-- = c;
if (ctx->be) {

if (ctx->collect_tgt + 1 >= &ctx->item.opcode)
*ctx->collect_tgt = c;
else
*ctx->collect_tgt++ = c;

} else {

if (ctx->collect_tgt <= (uint8_t *)&ctx->item.u)
*ctx->collect_tgt = c;
else
*ctx->collect_tgt-- = c;

}

if (--st->collect_rem)
break;
Expand Down

0 comments on commit 090ec8e

Please sign in to comment.