Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Fix a bug in number_format()
Summary: In case of error while calling snprintf, return empty string instead of malformed string. Reviewed By: binliu19 Differential Revision: D13379372 fbshipit-source-id: 1e5611598464daccc674d5a96558c9f2aee08fc8
- Loading branch information
Showing
3 changed files
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| <?php | ||
| $READ_LENGTH = 0x1000; // choose leak size | ||
| // construct fake iptc header for controlled read | ||
| $iptc_hdr = | ||
| "\x1c\x01" . // magic | ||
| "\x00\x80" . // dataset, recnum | ||
| "\x00" . // padding | ||
| pack("N", $READ_LENGTH); | ||
| // spray a bit so it's near the broken string | ||
| $holder = []; | ||
| for($i = 0; $i < 100; $i++) | ||
| $holder[] = str_pad($iptc_hdr, 96); | ||
| // trigger bug to create string with len=-1 | ||
| $badstr = number_format(0,0x7fffffff); | ||
| var_dump($badstr); | ||
| // leak memory :) | ||
| $tmp = iptcparse($badstr); | ||
| var_dump($tmp); | ||
| ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| string(0) "" | ||
| bool(false) |