Skip to content

Commit

Permalink
helper: fix out of bound access on unmarshal
Browse files Browse the repository at this point in the history
  • Loading branch information
onkwon committed Aug 7, 2023
1 parent 30bbd24 commit e89320c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/cbor/helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ extern "C" {

struct cbor_parser {
const void *key;
size_t keylen;
void (*run)(const cbor_reader_t *reader,
const struct cbor_parser *parser,
const cbor_item_t *item, void *arg);
Expand Down
2 changes: 1 addition & 1 deletion src/helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ static const struct cbor_parser *get_parser(const struct parser_ctx *ctx,
continue;
}

if (strkey && strkey_len) {
if (strkey && strkey_len && p->keylen >= strkey_len) {
if (memcmp(p->key, strkey, strkey_len) == 0) {
return p;
}
Expand Down

0 comments on commit e89320c

Please sign in to comment.