Skip to content

Commit 116498f

Browse files
committed
Fix potential buffer overflow in FNonZeroFiniteDblToStr
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.
1 parent 552f29a commit 116498f

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
@@ -2506,6 +2506,10 @@ BOOL Js::NumberUtilities::FNonZeroFiniteDblToStr(double dbl, _In_range_(2, 36) i
25062506
// handle negative number
25072507
if (0x80000000 & Js::NumberUtilities::LuHiDbl(dbl))
25082508
{
2509+
if (len < 2)
2510+
{
2511+
return FALSE;
2512+
}
25092513
*ppsz++ = '-';
25102514
len--;
25112515
Js::NumberUtilities::LuHiDbl(dbl) &= 0x7FFFFFFF;

0 commit comments

Comments
 (0)