Skip to content

Commit

Permalink
fix strdup() on possibly unterminated string
Browse files Browse the repository at this point in the history
Otherwise, a buffer read overflow may happen at
file.c line 236
  • Loading branch information
pauldreik committed Oct 31, 2019
1 parent 75b2146 commit 10e0216
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,11 @@ attr_read (FILE* in)
attr->type = (type_and_name >> 16);
attr->name = ((type_and_name << 16) >> 16);
attr->len = geti32(in);
attr->buf = CHECKED_XCALLOC (unsigned char, attr->len);
attr->buf = CHECKED_XCALLOC (unsigned char, attr->len + 1);

// fuzz - I think this should be null terminated?
(void)getbuf(in, attr->buf, attr->len);
attr->buf[attr->len]='\0';

checksum = geti16(in);
if (!check_checksum(attr, checksum))
Expand Down

0 comments on commit 10e0216

Please sign in to comment.