Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changes-entries/mime-magic-negative-offset.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*) mod_mime_magic: Reject negative indirect offsets in mget() so a crafted
file cannot drive an out-of-bounds read of the sniff buffer.
[arshiya tabasum]
4 changes: 2 additions & 2 deletions modules/metadata/mod_mime_magic.c
Original file line number Diff line number Diff line change
Expand Up @@ -1814,7 +1814,7 @@ static int mget(request_rec *r, union VALUETYPE *p, unsigned char *s,
{
long offset = m->offset;

if (offset + sizeof(union VALUETYPE) > nbytes)
if (offset < 0 || (apr_size_t)offset + sizeof(union VALUETYPE) > nbytes)
return 0;

memcpy(p, s + offset, sizeof(union VALUETYPE));
Expand All @@ -1836,7 +1836,7 @@ static int mget(request_rec *r, union VALUETYPE *p, unsigned char *s,
break;
}

if (offset + sizeof(union VALUETYPE) > nbytes)
if (offset < 0 || (apr_size_t)offset + sizeof(union VALUETYPE) > nbytes)
return 0;

memcpy(p, s + offset, sizeof(union VALUETYPE));
Expand Down