From dce09b18b48837d8006694b9dc3b2d026e5e7869 Mon Sep 17 00:00:00 2001 From: Henrique Nakashima Date: Fri, 1 Sep 2017 12:14:26 -0400 Subject: Fix integer overflow in Buffer_itoa when passing INT_MIN. Bug: chromium:760034 Change-Id: Id0862749b1454e065de4de7d746a27e78ac58e30 Reviewed-on: https://pdfium-review.googlesource.com/12730 Commit-Queue: Henrique Nakashima Reviewed-by: Tom Sepez --- core/fxcrt/cfx_bytestring_unittest.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'core/fxcrt/cfx_bytestring_unittest.cpp') diff --git a/core/fxcrt/cfx_bytestring_unittest.cpp b/core/fxcrt/cfx_bytestring_unittest.cpp index 497e0b6c2f..a590af3b14 100644 --- a/core/fxcrt/cfx_bytestring_unittest.cpp +++ b/core/fxcrt/cfx_bytestring_unittest.cpp @@ -1511,3 +1511,18 @@ TEST(fxcrt, OStreamByteStringCOverload) { EXPECT_EQ("abcdef", stream.str()); } } + +TEST(fxcrt, ByteStringFormatInteger) { + // Base case of 0. + EXPECT_EQ("0", CFX_ByteString::FormatInteger(0)); + + // Positive ordinary number. + EXPECT_EQ("123456", CFX_ByteString::FormatInteger(123456)); + + // Negative ordinary number. + EXPECT_EQ("-123456", CFX_ByteString::FormatInteger(-123456)); + + // int limits. + EXPECT_EQ("2147483647", CFX_ByteString::FormatInteger(INT_MAX)); + EXPECT_EQ("-2147483648", CFX_ByteString::FormatInteger(INT_MIN)); +} -- cgit v1.2.3