From 46e8ecf84c0227298c5aca8ea587bd6b2bce4c87 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Fri, 30 Jun 2017 18:06:36 -0700 Subject: M60: Fix a buffer overflow in FPDFPage_Flatten(). BUG=chromium:732661 TBR=dsinclair@chromium.org Change-Id: Ie11a7d97db97ac969fb6230956efbf21c2ed3d87 Reviewed-on: https://pdfium-review.googlesource.com/6555 Commit-Queue: dsinclair Reviewed-by: dsinclair (cherry picked from commit f0f2a2a528e154b8ceeded297abc3a64007850f8) Reviewed-on: https://pdfium-review.googlesource.com/7231 Reviewed-by: Lei Zhang Commit-Queue: Lei Zhang --- fpdfsdk/fpdf_flatten.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'fpdfsdk/fpdf_flatten.cpp') diff --git a/fpdfsdk/fpdf_flatten.cpp b/fpdfsdk/fpdf_flatten.cpp index 0477d6fea5..914008c1a3 100644 --- a/fpdfsdk/fpdf_flatten.cpp +++ b/fpdfsdk/fpdf_flatten.cpp @@ -305,15 +305,18 @@ DLLEXPORT int STDCALL FPDFPage_Flatten(FPDF_PAGE page, int nFlag) { if (!pPageXObject) pPageXObject = pRes->SetNewFor("XObject"); - CFX_ByteString key = ""; + CFX_ByteString key; int nStreams = pdfium::CollectionSize(ObjectArray); if (nStreams > 0) { - for (int iKey = 0; /*iKey < 100*/; iKey++) { - char sExtend[5] = {}; - FXSYS_itoa(iKey, sExtend, 10); - key = CFX_ByteString("FFT") + CFX_ByteString(sExtend); - if (!pPageXObject->KeyExist(key)) + CFX_ByteString sKey; + int i = 0; + while (i < INT_MAX) { + sKey.Format("FFT%d", i); + if (!pPageXObject->KeyExist(sKey)) { + key = sKey; break; + } + ++i; } } -- cgit v1.2.3