Skip to content

Commit

Permalink
0003_bug_71459_integer_overflow_in_iptcembed
Browse files Browse the repository at this point in the history
Summary: Don't overflow in iptcembed.

Reviewed By: paulbiss

Differential Revision: D3209224

fbshipit-source-id: feaca9fd861d28a3d542a17512ffd5e340f99608
  • Loading branch information
Orvid authored and Hhvm Bot committed Jun 4, 2016
1 parent 4e614ba commit 381702f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions hphp/runtime/ext/gd/ext_gd.cpp
Expand Up @@ -4582,6 +4582,11 @@ Variant HHVM_FUNCTION(iptcembed, const String& iptcdata,
return false;
}

if (iptcdata_len >= (INT64_MAX - sizeof(psheader) - st_size - 1024 - 1)) {
raise_warning("iptcdata too long");
return false;
}

auto malloc_size = iptcdata_len + sizeof(psheader) + st_size + 1024 + 1;
poi = spoolbuf = (unsigned char *)IM_MALLOC(malloc_size);
CHECK_ALLOC_R(poi, malloc_size, false);
Expand Down

0 comments on commit 381702f

Please sign in to comment.