summaryrefslogtreecommitdiff
path: root/fpdfsdk
AgeCommit message (Collapse)Author
2017-10-04Fix UAF in SetVisible().Henrique Nakashima
SetVisible() may be called during Destroy() which may be called during SetVisible(). This fixes the latest in a family of bugs that happen after an instance is freed by code triggered by JS code while it's executing a method. The CL has a lot of protection for many of these points where JS may be executed and potentially destroy objects. The return types of many methods that may execute JS have been changed to bool, indicating whether the instance is still alive after the call. Bug: chromium:770148 Change-Id: If5a9db4d8d6aac10f4dd6b645922bb96c116684d Reviewed-on: https://pdfium-review.googlesource.com/15190 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
2017-10-03Improve CPDF_ReadVaildatorArtem Strygin
Merge CPDF_ReadValidator::IsXXXAvailable and CPDF_ReadValidator::SheduleXXXDowload methods into one CheckXXXAndRequestIfUnavailable. Change-Id: Ib108d5bc3589df17269c841b0024dd4690909304 Reviewed-on: https://pdfium-review.googlesource.com/13730 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Art Snake <art-snake@yandex-team.ru>
2017-10-02More define cleanupDan Sinclair
Remove unused defines; Move to .cpp files where possible; Fixup values. Change-Id: I88cd5deb04b14ab8e9f8097a695c3d0b52d64b4c Reviewed-on: https://pdfium-review.googlesource.com/15130 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-10-02Allow to use null FX_DOWNLOADHINTS to check data availabilityArtem Strygin
This is allow us check document/pages/form availability using FPDFAvail_IsXXAvail without download requests. Change-Id: Ie4525147d8b8e98573d53b2e5b456b632a8a1951 Reviewed-on: https://pdfium-review.googlesource.com/13030 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Art Snake <art-snake@yandex-team.ru>
2017-09-28Cleanup font definesDan Sinclair
Use methods to match font information; cleanup some font code. Change-Id: Ib99c1e466e56723cb5d264d49e1caf9bbbc0daed Reviewed-on: https://pdfium-review.googlesource.com/15072 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-09-28Add Length1 in TrueType font streamsNicolás Peña
Bug: pdfium:892 Change-Id: Ica0377515589a96a8919cb8ed2a3da1d1c9f6191 Reviewed-on: https://pdfium-review.googlesource.com/15030 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
2017-09-28Implement FakeFileAccess.Artem Strygin
Update embedder tests to simulate unavailable data and download requests. Change-Id: I634fa89d2a0c859243e849752936da87568909f4 Reviewed-on: https://pdfium-review.googlesource.com/11890 Commit-Queue: Art Snake <art-snake@yandex-team.ru> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-09-28Fix load non first pages in linearized document with hints table.Artem Strygin
Tha problem was, that when we use hints tables, we do not check pages tree availability, but currently for receiving page object in CPDF_Document, the pages tree should be available anyway. Change-Id: I908d00027fd8727f074a38e47fea095229ef5147 Reviewed-on: https://pdfium-review.googlesource.com/11892 Commit-Queue: Art Snake <art-snake@yandex-team.ru> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-09-28Fix infinite loop on form availability check.Artem Strygin
The problem was, that the CPDF_SyntaxParser read last block not from requested position. In this case It move down requested position to fill whole buffer. As result this additional data was not requested by DownloadHints. To fix this allow resize data buffer in CPDF_SyntaxParser, to store more small block, and always read from requsted position. Also add reading check into CPDF_Parser::LoadLinearizedMainXRefTable to prevent infinite loops. Change-Id: I14d3f4457393025dca390aa3ceaa940716463534 Reviewed-on: https://pdfium-review.googlesource.com/11891 Commit-Queue: Art Snake <art-snake@yandex-team.ru> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-09-28Change bottom-top order in FontBBoxNicolás Peña
The FontBBox, for compatiblity reasons, must be specified top to bottom. This CL flips the current implementation which was bottom to top. Bug: pdfium:892 Change-Id: Ieb8d3bb183ed7870e3b3d7f0380f1343adedf87b Reviewed-on: https://pdfium-review.googlesource.com/14851 Commit-Queue: Nicolás Peña Moreno <npm@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-09-27Move CFX_Font definition to cfx_font.hDan Sinclair
This CL moves the CFX_Font definition out of fx_font.h and into cfx_font.h to match the cfx_font.cpp implementation. Change-Id: Icc2fc7463fa4b9d0bec925e80b60a638136a83a1 Reviewed-on: https://pdfium-review.googlesource.com/14951 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2017-09-27Remove FXSYS_strlen and FXSYS_wcslenchromium/3226Ryan Harrison
With the conversion of internal string sizes to size_t, these wrappers are no longer needed. Replacing them with strlen and wcslen respectively. BUG=pdfium:828 Change-Id: Ia087ca2ddaf688a57ec9bd9ddfb8533cbe41510d Reviewed-on: https://pdfium-review.googlesource.com/14890 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-09-27Remove FX_STRSIZE and replace with size_tRyan Harrison
BUG=pdfium:828 Change-Id: I5c40237433ebabaeabdb43aec9cdf783e41dfe16 Reviewed-on: https://pdfium-review.googlesource.com/13230 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2017-09-27Cleanup FX macrosDan Sinclair
This CL renames the FX_OS defines to have _OS_ in their names and drops the _DESKTOP suffix. The FXM defines have been changed to just FX. Change-Id: Iab172fba541713b5f6d14fb8098baf68e3364c74 Reviewed-on: https://pdfium-review.googlesource.com/14833 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-09-26Rename CFPDF_* classesDan Sinclair
This CL removes the CFPDF_* prefix. The classes have been renamed to their FPDF_* name with Context appended to the end. This makes it easier to differentiate things like CPDF_DataAvail vs CFPDF_DataAvail as the former is now FPDF_AvailContext. Change-Id: I4a97727b3418de268c8494eaca2ed413b5cc2954 Reviewed-on: https://pdfium-review.googlesource.com/14810 Reviewed-by: Art Snake <art-snake@yandex-team.ru> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-09-25API: rename FPDFPage_CountObject() to FPDFPage_CountObjects()Miklos Vajna
Keep the old name, but mark it as deprecated and don't use it in own code. Change-Id: I17b88dccacf494a03562c0d003cfcb2bc03bf430 Reviewed-on: https://pdfium-review.googlesource.com/14750 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-09-22Fix UAF after destroying a widget during OnBeforeKeyStroke().chromium/3223Henrique Nakashima
Bug: chromium:766957 Change-Id: I61b282059fb4fc2c8ba6dafc502f030f31dd324d Reviewed-on: https://pdfium-review.googlesource.com/14710 Commit-Queue: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-09-22API: rename FPDFPath_CountPoint() to FPDFPath_CountSegments()Miklos Vajna
This was the last place talking about "point objects". Change-Id: Ib5f5d5b8efdd674ca5902ff82c2bd4d9f2db8bb1 Reviewed-on: https://pdfium-review.googlesource.com/14651 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-09-21Move CFX_UnownedPtr to UnownedPtrDan Sinclair
This CL moves CFX_UnownedPtr to UnownedPtr and places in the fxcrt namespace. Bug: pdfium:898 Change-Id: I6d1fa463f365e5cb3aafa8c8a7a5f7eff62ed8e0 Reviewed-on: https://pdfium-review.googlesource.com/14620 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-09-21Rename CFX_RetainPtr to RetainPtrDan Sinclair
This CL renames CFX_RetainPtr to RetainPtr and places in the fxcrt namespace. Bug: pdfium:898 Change-Id: I8798a9f79cb0840d3f037e8d04937cedd742914e Reviewed-on: https://pdfium-review.googlesource.com/14616 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-09-21Move CFX_Observable to ObservableDan Sinclair
This CL renames CFX_Observable to Observable and moves into the fxcrt namespace. The test suite names were updated to ObservedPtr from fxcrt. Bug: pdfium:898 Change-Id: Ia507482bc0a1d6d8bbf12c0c55c4a88f6c8910e2 Reviewed-on: https://pdfium-review.googlesource.com/14615 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-09-21Rename CXFA_DefFontMgr to CFGAS_DefaultFontManagerDan Sinclair
This CL removes any XFA requirements on the default font manager and moves it to the fgas/ directory. Some helper methods from CXFA_FontMgr are moved into the fgas/fgas_fontutils.h files. Change-Id: I17ba8dc2bd60085c17d8a3328f6625675a82787f Reviewed-on: https://pdfium-review.googlesource.com/14570 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-09-21Move CFX_AutoRestorer to fxcrt::AutoRestorerDan Sinclair
This CL renames CFX_AutoRestorer to just AutoRestorer and places in the fxcrt namespace. Bug: pdfium:898 Change-Id: Id9f36df94e95f3b2a55054bc198ca1bfd249ee3d Reviewed-on: https://pdfium-review.googlesource.com/14450 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-09-21Add embeddertest for CFWL_EditDan Sinclair
This CL adds two mouse selection tests for CFWL_Edit. In order to do so the needed selection code was added to the XFA widget handler and plumbed down to the CFWL_Edit field as needed. Bug: pdfium:840 Change-Id: Ia3b5f5d191494a4579c01524df8fb35b24cc0085 Reviewed-on: https://pdfium-review.googlesource.com/14530 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-09-20Add FPDFPath_GetPoint() APIchromium/3221Miklos Vajna
Combined with the previously added FPDFPath_CountPoint(), this allows getting the coordinates of all points of a path. Change-Id: Ic969723d4b01ee427498d38ce323c74147b87a9c Reviewed-on: https://pdfium-review.googlesource.com/14111 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-09-20Cleanup CPWL_Caret codeDan Sinclair
Add some early returns where possible. Change-Id: I9c53435e6e927057b085b1ccaa30a1637c185486 Reviewed-on: https://pdfium-review.googlesource.com/14350 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-09-19Fix draw order of popup annotations.Henrique Nakashima
Bug: chromium:765375 Change-Id: Ifdbd33ca92ec7105778788f891095eaf280c18cf Reviewed-on: https://pdfium-review.googlesource.com/14370 Commit-Queue: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-09-19Remove unneeded core/fxcodec/fx_codec.h includes.chromium/3220Lei Zhang
Change-Id: I703321108712e8c4a11a8343ecf8b1a8804c1d1a Reviewed-on: https://pdfium-review.googlesource.com/14352 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2017-09-19Setting focus on a widget may destroy the widgetDan Sinclair
When a widget has focus set, this can trigger an Invalidation call which can trigger a page and annotation reload. This reload can destroy the current widget we're handling. This CL adds ObservedPtrs as needed so we can make sure the widgets are still alive after we've done the Invalidation. Bug: chromium:765921 Change-Id: I51cd24aa1ebd96abe9478efef5130a4e568dac1a Reviewed-on: https://pdfium-review.googlesource.com/14290 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-09-19Remove unused methods and field in CFFL_FormFiller.Henrique Nakashima
Change-Id: Ice5ef31af6e32b6a02072e2a4445b19d4f801d3c Reviewed-on: https://pdfium-review.googlesource.com/14330 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
2017-09-18Convert string class namesRyan Harrison
Automated using git grep & sed. Replace StringC classes with StringView classes. Remove the CFX_ prefix and put string classes in fxcrt namespace. Change AsStringC() to AsStringView(). Rename tests from TEST(fxcrt, *String*Foo) to TEST(*String*, Foo). Couple of tests needed to have their names regularlized. BUG=pdfium:894 Change-Id: I7ca038685c8d803795f3ed02545124f7a224c83d Reviewed-on: https://pdfium-review.googlesource.com/14151 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2017-09-15Use unsigned types for app age, value age in widgets.chromium/3218chromium/3217Tom Sepez
Then if they roll over, it doesn't matter, since we only check for change. And then we can pull a silly check. Then remove some no-op calls where we didn't use the result. Change-Id: I35ba470b42fb8c32a6984999e0311b21729791ca Reviewed-on: https://pdfium-review.googlesource.com/14210 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2017-09-15Introduce CPWL_Wnd::PrivateData class.Tom Sepez
First step in passing ownership of this memory to the CPWL_Wnd. In turn, nest two other classes that also require PrivateData to satisfy nesting rules. Move one stray #define to the appropriate file while at it. Change-Id: I565934565421f5843a3b792b3bdc21b5e8839eb8 Reviewed-on: https://pdfium-review.googlesource.com/14170 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2017-09-15Move CPWL_CREATPARAM to CPWL_Wnd::CreateParamsTom Sepez
This nesting makes so much more sense when I read the code. Fix member naming for this in CPWL_Wnd. Pass in/out CreateParams arg as pointer. Kill Reset() method, only called during destroy and nothing needs explicit cleanup. Change-Id: If50e403e11c131e7656da09c0cb36866223d64c6 Reviewed-on: https://pdfium-review.googlesource.com/14070 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2017-09-15Add ObservedPtrs to KillFocus pathRyan Harrison
This is to prevent use after free issues due to these calls causing reloads of content that have the side of effect of destroying windows. BUG=chromium:760455 Change-Id: I3f3947be8b32964783abf5577a24ba6a713b3476 Reviewed-on: https://pdfium-review.googlesource.com/14150 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-09-15Add public method FPDFPath_CountPoint to get # of points of a path object.Miklos Vajna
It was already possible to get the fill color, this exposes the number of points. Naming attempts to be consistent with existing FPDFPage_CountObject(). Change-Id: I79e8dd9f0c077de84ce9017a01d239e48e58174a Reviewed-on: https://pdfium-review.googlesource.com/13592 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2017-09-15Make static const char* arrays more const.Lei Zhang
Change-Id: I87b5e6cefe973b82b4868e56fc5285c95c53a12b Reviewed-on: https://pdfium-review.googlesource.com/12550 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2017-09-15OnBeforeKeystroke may invalidate the widget's window.Tom Sepez
And along with it any data that the window may have been carrying. Tidy some return codes while we're at it. Bug: 765384 Change-Id: Id16ec5f82b3d9273ba8f2edb1e4645a9145df4f6 Reviewed-on: https://pdfium-review.googlesource.com/14050 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2017-09-14Checkbox event fixed when triggered by a keyboard entryClaudio DeSouza
The event was changed to behave in the same way as when reacting to a mouse click event. R=thestig@chromium.org Bug: pdfium:897 Change-Id: I14366d69ad309e00cb1dd78672870d1ee95007a9 Reviewed-on: https://pdfium-review.googlesource.com/13990 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2017-09-14Add more FPDF_GetMetaText() tests.Lei Zhang
Change-Id: I27d26691a3b7bd8593581483d4a21729040fbe95 Reviewed-on: https://pdfium-review.googlesource.com/13910 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2017-09-14Add tests for FPDF_GetMetaText().Lei Zhang
Change-Id: I8d2eaea9696b6ac4ea7ba5cb323bf74546c31d46 Reviewed-on: https://pdfium-review.googlesource.com/13890 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2017-09-14Fix CPDFPathObjectFromFPDFPageObject() implementation.Lei Zhang
It should make sure the FPDF_PAGEOJECT passed in is actually a path. Change-Id: I89d0626dc350fd2f65b08282b276a4de2c3a7398 Reviewed-on: https://pdfium-review.googlesource.com/13710 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2017-09-13Change behaviour of FPDF_RenderPageBitmapWithMatrixNicolas Pena
This CL changes the behavior of FPDF_RenderPageBitmapWithMatrix so it transforms the bitmap. Before, the page would be transformed and the assumption was that it would be drawn on a bitmap with the same dimensions as the original page. This does not work well because a transformation generally changes the dimensions of the page. The rectangles test is modified to include small rectangles in the corner of the page, so that it's clear that the whole original page is being displayed. Bug: pdfium:849 Change-Id: Ie89f959a1605fea59a15d239ca871ccd939ec92b Reviewed-on: https://pdfium-review.googlesource.com/13510 Commit-Queue: Nicolás Peña <npm@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2017-09-13Add readme files to some directories.chromium/3215Henrique Nakashima
Change-Id: I2a750c8e46b68dc4870e2dadd2ed3429008e1562 Reviewed-on: https://pdfium-review.googlesource.com/13551 Commit-Queue: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2017-09-12Remove ASSERT that was added to understand what was occuringRyan Harrison
thestig provided a test PDF that reproduced the issue that is being tested for in the ASSERT. I have spent some time going throught the related code, and the condition in the assert is actually standard behaviour, so shouldn't be asserted. The following code gracefully handles the case of more text then requested being returned. BUG=chromium:763369 Change-Id: I5bc121977169deead52fc5dd2503376b1b62d83f Reviewed-on: https://pdfium-review.googlesource.com/13750 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2017-09-11Add guard against reading more then expected from the pageRyan Harrison
This really shouldn't ever happen, but there used to be this guard in this code and I am getting reports of crashes after it was removed. I have added an assert, so hopefully if it is actually occuring, then we might get a reproduction case based on a debug build crash. BUG=chromium:763369 Change-Id: Ifaebfbcb0413a1d7777222ba838aaee234f94ae3 Reviewed-on: https://pdfium-review.googlesource.com/13691 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2017-09-06Convert FX_STRSIZE int->size_tRyan Harrison
Change the underlying type for FX_STRSIZE to size_t from int. This will make the value unsigned and thus all values in the range of the type will be valid. This allows for the final remove of negative length strings, but also introduces a some casting and functional errors, since many parts of the code base assume that FX_STRSIZE is int or another signed type. This also CL fixes these errors. BUG=pdfium:828 Change-Id: I231dca59e96fc9330cbb099eecbdfc41fcf86f5b Reviewed-on: https://pdfium-review.googlesource.com/11830 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2017-09-05Leave space for null characters when getting textRyan Harrison
The conversion from WideString to ByeString adds in null characters at the end, so we need to account for these when selecting the range of text to initially extract. BUG=chromium:761770,chromium:761626 Change-Id: Ib8f863e997ebccaaf882e0beb29733f27a18826d Reviewed-on: https://pdfium-review.googlesource.com/13110 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-09-01Prepare for converting FX_STRSIZE int->size_tRyan Harrison
When turning on this conversion a number of typing issues and other nits where found in the code base that can be merged in without actually changing the underlying type. Landing these changes before the type change CL, since there is a high likelihood that the type change will need to be rolled back, since it is high risk. BUG=pdfium:828 Change-Id: I587443d9090055963446485a1aacb8772eb5ca64 Reviewed-on: https://pdfium-review.googlesource.com/12810 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2017-09-01Adjust loops in preperation for FX_STRSIZE int->size_tRyan Harrison
Adjust loop conditions and behaviours in preperation for convering the underlying type of FX_STRSIZE to size_t. These changes are not dependent on the type switch occuring, so can be landed before hand. BUG=pdfium:828 Change-Id: I5f950c99c10e5ef0836959e3b1dd2e09f8f5afc0 Reviewed-on: https://pdfium-review.googlesource.com/12750 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>