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
string_number_format: Correctly handles return value of snprintf
Summary: `snprintf` can return a value greater than the number of bytes copied. In case the first byte of the string is not a digit (could be '-'), size of `tmpstr` was being updated without checking `tmplen`. This resulted in either an assertion error or a heap overflow depending on whether the assertion is compiled or not. Reviewed By: mofarrell, qianxuweiren Differential Revision: D17327899 fbshipit-source-id: ee53875d21e02608c6d870388eecf1464de24ff1
- Loading branch information
1 parent
ef76449
commit dbeb9a5
Showing
3 changed files
with
15 additions
and
1 deletion.
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,9 @@ | ||
| <?hh | ||
| // Copyright 2004-present Facebook. All Rights Reserved. | ||
|
|
||
| <<__EntryPoint>> | ||
| function main() { | ||
| $bin_repr = "\x00\x00\x00\x00\x00\x00\x00\x80"; | ||
| $double_num = unpack("dnum", $bin_repr)['num']; | ||
| var_dump(number_format($double_num, 100)); | ||
| } |
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 @@ | ||
| string(103) "-0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" |