Skip to content

Commit dcecda5

Browse files
committed
[MERGE #4888 @xiaoyinl] Check buffer length in FNonZeroFiniteDblToStr
Merge pull request #4888 from xiaoyinl:dbltostr_len For the function `Js::NumberUtilities::FNonZeroFiniteDblToStr` (in `NumberUtilities_strtod.cpp`), if the input double value `dbl` is negative and `nDstBufSize` is zero, there's a buffer overflow. The buffer length is not checked before the buffer `ppsz` is written. This is not currently triggerable, since all callers pass a 256 byte buffer. But I think it's good to check the length here just in case.
2 parents a2d89ae + 116498f commit dcecda5

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/Common/Common/NumberUtilities_strtod.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2507,6 +2507,10 @@ BOOL Js::NumberUtilities::FNonZeroFiniteDblToStr(double dbl, _In_range_(2, 36) i
25072507
// handle negative number
25082508
if (0x80000000 & Js::NumberUtilities::LuHiDbl(dbl))
25092509
{
2510+
if (len < 2)
2511+
{
2512+
return FALSE;
2513+
}
25102514
*ppsz++ = '-';
25112515
len--;
25122516
Js::NumberUtilities::LuHiDbl(dbl) &= 0x7FFFFFFF;

0 commit comments

Comments
 (0)