pdfium.git
4 years agoUse static_assert unconditionally.
Peter Kasting [Sat, 27 Sep 2014 01:09:20 +0000]
Use static_assert unconditionally.

BUG=none
TEST=none
R=jam@chromium.org

Review URL: https://codereview.chromium.org/605273004

4 years agoRename GN public variables.
Brett Wilson [Wed, 24 Sep 2014 22:32:49 +0000]
Rename GN public variables.

forward_dependent_configs_from => public_deps
direct_dependent_configs => public_configs

R=jam@chromium.org

Review URL: https://codereview.chromium.org/598093002

4 years agoLock page in LoadFXAnnot to prevent unintended page closing
Bo Xu [Wed, 24 Sep 2014 17:49:52 +0000]
Lock page in LoadFXAnnot to prevent unintended page closing

BUG=410326
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/594403003

4 years agoInvoke V8::Initialize() explicitly during V8 setup
Jochen Eisinger [Mon, 22 Sep 2014 06:46:17 +0000]
Invoke V8::Initialize() explicitly during V8 setup

BUG=none
R=jam@chromium.org

Review URL: https://codereview.chromium.org/581413002

4 years agoAdd FPDF_GetSecurityHandlerRevision
Bo Xu [Sat, 20 Sep 2014 02:16:31 +0000]
Add FPDF_GetSecurityHandlerRevision

Security handler revision number is needed to interpret file permission.

BUG=None
R=thestig@chromium.org

Review URL: https://codereview.chromium.org/589813002

4 years agoFix a bug when assign the generation number of indirect objects
Bo Xu [Fri, 19 Sep 2014 22:58:46 +0000]
Fix a bug when assign the generation number of indirect objects

BUG=408532
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/524443002

4 years agoAdjust the order of clearing resource in CPDF_DocPageData::Clear
Jun Fang [Fri, 19 Sep 2014 21:51:51 +0000]
Adjust the order of clearing resource in CPDF_DocPageData::Clear

Images are basic resource and are referred or used by other objects in some cases. Images should be released after the objects who uses these objects. In this case, an image object is accessed in the process of CPDF_TilingPattern's destroy. Unlikely, this image has been destroyed before.

BUG=414046
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/582993002

4 years agoFix Regression: Incomplete file loading is seen for multi page pdf files.
Tom Sepez [Thu, 18 Sep 2014 19:11:56 +0000]
Fix Regression: Incomplete file loading is seen for multi page pdf files.

This was introduced at PDFium revision 12a9940. There was a subtle logic
change for null |parray|.

BUG=415438
R=jun_fang@foxitsoftware.com

Review URL: https://codereview.chromium.org/579363002

4 years agogn: don't remove -fno-exceptions to match gyp
Scott Graham [Thu, 18 Sep 2014 16:28:58 +0000]
gn: don't remove -fno-exceptions to match gyp

Not required since: https://code.google.com/p/pdfium/issues/detail?id=28

R=jam@chromium.org
BUG=chromium:335824

Review URL: https://codereview.chromium.org/567393004

5 years agoWhen forcing clear page data, no need to release colorspace when releasing pattern
Bo Xu [Tue, 16 Sep 2014 20:24:37 +0000]
When forcing clear page data, no need to release colorspace when releasing pattern

BUG=414661
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/572853006

5 years agoAdd a boundary check before accessing the table of 'Index to Location'
Jun Fang [Tue, 16 Sep 2014 04:50:59 +0000]
Add a boundary check before accessing the table of 'Index to Location'

Before this fix, only |gindex < face->num_locations| is checked. However, the pointer, p, will be moved to next location in the first FT_NEXT_ULONG or FT_NEXT_USHORT. It may cause a crashier. So a boundary check is needed before the second FT_NEXT_ULONG or FT_NEXT_USHORT.

BUG=412457
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/571833002

5 years agoCheck Null pointer in CPDF_Dictionary::GetUnicodeText
Bo Xu [Mon, 15 Sep 2014 18:28:25 +0000]
Check Null pointer in CPDF_Dictionary::GetUnicodeText

BUG=414155
R=thakis@chromium.org

Review URL: https://codereview.chromium.org/574463002

5 years agoFix hebrew character highlight issue in a special document
Bo Xu [Thu, 11 Sep 2014 21:26:42 +0000]
Fix hebrew character highlight issue in a special document

There is an image object and text objects in this document, but the character in each text object is reversed.
When rendering, the image object is shown.
However, when highlighting, the text object is selected, resulting in text index issue.
Moreover, the character in the document is in reading order, which is different from normal document.

BUG=pdfium:43
R=jbreiden@google.com

Review URL: https://codereview.chromium.org/484503002

5 years agoCheck object type for objects used in the dictory of 'Index'
Jun Fang [Wed, 10 Sep 2014 23:11:45 +0000]
Check object type for objects used in the dictory of 'Index'

BUG=387970
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/551503003

5 years agoChange the forced clear order of CPDF_DocPageData::Clear, and remove m_pDocument...
Bo Xu [Wed, 10 Sep 2014 01:39:30 +0000]
Change the forced clear order of CPDF_DocPageData::Clear, and remove m_pDocument in CPDF_Color

If not forced clear, the counter of CPDF_Pattern will take care the count of referenced instance.
When forced clear, clear color first to make sure pattern still exists when referencing it.

BUG=411154
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/554913003

5 years agoFix uninitialized value in CPDF_ColorStateData
Bo Xu [Wed, 10 Sep 2014 01:32:05 +0000]
Fix uninitialized value in CPDF_ColorStateData

BUG=411161
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/560673002

5 years agoRevert of Fix uninitialized value in CPDF_ColorStateData (patchset #1 id:1 of https...
Bo Xu [Wed, 10 Sep 2014 00:36:01 +0000]
Revert of Fix uninitialized value in CPDF_ColorStateData (patchset #1 id:1 of https://codereview.chromium.org/547863002/)

Reason for revert:
The initialized member variable is wrong. Needs to undo this.

Original issue's description:
> Fix uninitialized value in CPDF_ColorStateData
>
> BUG=411161
> R=tsepez@chromium.org
>
> Committed: https://pdfium.googlesource.com/pdfium/+/a38d4c3572b566f8e64b9ca4f725cbbc581e85ab

TBR=tsepez@chromium.org,jun_fang@foxitsoftware.com
NOTREECHECKS=true
NOTRY=true
BUG=411161

Review URL: https://codereview.chromium.org/558803004

5 years agoFix uninitialized value in CPDF_ColorStateData
Bo Xu [Tue, 9 Sep 2014 00:35:04 +0000]
Fix uninitialized value in CPDF_ColorStateData

BUG=411161
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/547863002

5 years agoFix un-initialized R G B value
Bo Xu [Tue, 9 Sep 2014 00:28:16 +0000]
Fix un-initialized R G B value

BUG=411163
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/551513005

5 years agoConvert GN visibility to be a list.
Brett Wilson [Mon, 8 Sep 2014 23:36:48 +0000]
Convert GN visibility to be a list.

GN visibility currently allows either string or list types, but this is causing
some problems for some templates. I'm going to require it to be lists, so am
changing all callers before pushing the new binary.

R=jam@chromium.org

Review URL: https://codereview.chromium.org/555523002

5 years agoMerge performance fix for cmsDupToneCurve from previous upstream branch.
Chris Palmer [Mon, 8 Sep 2014 23:12:10 +0000]
Merge performance fix for cmsDupToneCurve from previous upstream branch.

BUG=
R=jun_fang@foxitsoftware.com

Review URL: https://codereview.chromium.org/534363002

5 years agoThe cause of this issue is that there is an indirect object like '112 0 R' but no...
Jun Fang [Mon, 8 Sep 2014 18:27:02 +0000]
The cause of this issue is that there is an indirect object like '112 0 R' but no its direct object '112 0 object' in the test pdf file. Without checking the validity, it causes a null pointer when trying to get the direct object by an indirect object.

BUG=390781
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/553613003

5 years agoAdd v8_platform to the JS dependencies in the GN build.
Brett Wilson [Thu, 4 Sep 2014 20:48:16 +0000]
Add v8_platform to the JS dependencies in the GN build.

This is required for the call to v8::platform::CreateDefaultPlatform.

R=jam@chromium.org

Review URL: https://codereview.chromium.org/540133002

5 years agoAllocate m_pCompData when |m_nComponents| is updated.
Bo Xu [Wed, 3 Sep 2014 20:30:43 +0000]
Allocate m_pCompData when |m_nComponents| is updated.

When |m_nComponents| is changed from loading stream information,
previously allocated memory that depends on |m_nComponents| needes to be freed
and allocated again to enforce memory size consistency.

BUG=409695
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/528163002

5 years agoCheck m_nComponents when using JBIG2Decode
Bo Xu [Tue, 2 Sep 2014 22:36:34 +0000]
Check m_nComponents when using JBIG2Decode

BUG=409692
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/534763002

5 years agoAdd m_pDocument in CPDF_Color and check if page date has been forced clear
Bo Xu [Tue, 2 Sep 2014 19:13:36 +0000]
Add m_pDocument in CPDF_Color and check if page date has been forced clear

This will prevent using freed pattern object.
This is a better solution than https://pdfium.googlesource.com/pdfium/+/1b9c5c4dc41956b8c5ab17b9a882adf8a2513768
and in essence revert that patch

BUG=409373
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/522483003

5 years agoTidy up opj_ callback functions in fx_codec_jpx_obj.cpp
Tom Sepez [Tue, 2 Sep 2014 17:27:47 +0000]
Tidy up opj_ callback functions in fx_codec_jpx_obj.cpp

This is code cleanup rather than bug fixing.

The motivation for this was to fix the casts at line 97 of the original file.  These are wrong; you cannot correct via casting a function signature mismatch when passing a function as an argument.  In theory, there's no reason to believe that the compiler will pass args in the same manner for a function of type (void*, size_t, void*) as for a function of type (void*, size_t, some_struct*).  The cast will suppress the compile error, but you can't be assured the call will work as intended.  In practice, it does, since the last architecture where a void* had a different representation than a struct* went extinct in the late 80s.

In the functions themselves, note that we currently bail out if srcData->offset >= srcData->src_size, so the expression
   bufferLength = (OPJ_SIZE_T)(srcData->src_size - srcData->offset)

will always be > 0.  Hence the check
   if(bufferLength <= 0)
is pointless, esp. since bufferLength is a signed type and < 0 makes no sense.

The opj_seek_from_memory() has a bool return value, so returning -1 on error doesn't seem reasonable.  Change this to TRUE/FALSE, and return false on seek past end.

If we're truly passing readonly data, then perhaps it makes sense to make the write() function always return -1. I didn't do this.

Lastly, I capitalize "DecodeData" so that it looks like a struct, and change its members to be size_t's to avoid casting back and forth.

R=jun_fang@foxitsoftware.com

Review URL: https://codereview.chromium.org/507273003

5 years agoRemove the GetValidBpc check in application callers and move it to where m_bpc is...
Bo Xu [Sun, 31 Aug 2014 22:23:46 +0000]
Remove the GetValidBpc check in application callers and move it to where m_bpc is assigned.

The problem of using GetValidBpc() in each function call is it could result in mismatch as seen in this case:
in ContinueToLoadMask(), m_bpc is re-assigned to 1 if m_bImageMask==1 regardless of the value from GetValidBpc().
This will result in mismatch if another function use the value from GetValidBpc().

The solution could be checking m_bImageMask in another function to make sure m_bpc is consistent, but that makes the code too cumbersome.
Also, we have to bring and are bringing in more and more GetValidBpc check, and this will continue with other buggy documents. So better to fix it now.

The original rational to use GetValidBpc() in where m_bpc is used is to respect the "raw" data from parsing.
However, if it will be ignored anyway and using value from GetValidBpc(), we'd better correct it at the very beginning.

BUG=408541
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/518443002

5 years agoRemove unused fields and stack locals.
Chris Palmer [Thu, 28 Aug 2014 21:44:46 +0000]
Remove unused fields and stack locals.

Edge closer to getting PDFium to build in chromium_code mode.

BUG=https://code.google.com/p/pdfium/issues/detail?id=29
R=bo_xu@foxitsoftware.com

Review URL: https://codereview.chromium.org/437343002

5 years agoNo need to release resources in destructor of CPDF_ShadingObject
Bo Xu [Thu, 28 Aug 2014 18:49:17 +0000]
No need to release resources in destructor of CPDF_ShadingObject

CPDF_DocPageData::~CPDF_DocPageData() will force to release all resources, so no need to do it here, which can result in heap-use-after-free trouble.

BUG=408164
R=jun_fang@foxitsoftware.com, tsepez@chromium.org

Review URL: https://codereview.chromium.org/513063003

5 years agoRestrict index not be greater than row_size in TIFF_PredictLine
Bo Xu [Wed, 27 Aug 2014 23:01:41 +0000]
Restrict index not be greater than row_size in TIFF_PredictLine

There is not strict way to limit invalid value of |Colors| from dictionary. We can make sure |index| does not go out of boundary of row_size.

BUG=407614
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/509993003

5 years agoUse valid bpc value in LoadPalette() and ContinueToLoadMask()
Bo Xu [Wed, 27 Aug 2014 21:19:55 +0000]
Use valid bpc value in LoadPalette() and ContinueToLoadMask()

BUG=408141, 408147
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/508253003

5 years agoFix a bug when looping through m_pCompData
Bo Xu [Wed, 27 Aug 2014 20:13:42 +0000]
Fix a bug when looping through m_pCompData

BUG=408154
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/509613005

5 years agoBounds check before fixed-size memcmp() in CJPX_Decoder::Init().
Tom Sepez [Tue, 26 Aug 2014 23:35:12 +0000]
Bounds check before fixed-size memcmp() in CJPX_Decoder::Init().

BUG=407476
R=jun_fang@foxitsoftware.com

Review URL: https://codereview.chromium.org/489703004

5 years agoFix compile on mac: format string mismatch error.
Tom Sepez [Tue, 26 Aug 2014 21:03:25 +0000]
Fix compile on mac: format string mismatch error.

See http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_compile_dbg/builds/9542/steps/compile%20%28with%20patch%29/logs/stdio

TBR=jun_fang@foxitsoftware.com,

Review URL: https://codereview.chromium.org/506053003

5 years agoSet m_pLinearized to NULL after release
Bo Xu [Mon, 25 Aug 2014 22:22:07 +0000]
Set m_pLinearized to NULL after release

BUG=406868
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/504993002

5 years agoPerform better input checks in early steps of parser.
Tom Sepez [Mon, 25 Aug 2014 21:59:02 +0000]
Perform better input checks in early steps of parser.

BUG=406591
R=jun_fang@foxitsoftware.com

Review URL: https://codereview.chromium.org/501823003

5 years agoUse number of components from ICC profile and alternate color space
Bo Xu [Mon, 25 Aug 2014 20:45:17 +0000]
Use number of components from ICC profile and alternate color space

BUG=406806
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/503883002

5 years agoAdd GetValidBpc() check in CPDF_DIBSource::CreateDecoder()
Bo Xu [Mon, 25 Aug 2014 20:34:01 +0000]
Add GetValidBpc() check in CPDF_DIBSource::CreateDecoder()

BUG=406908
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/504673002

5 years agoAdd GetValidBpc() check in CPDF_DIBSource::GetScanLine
Bo Xu [Mon, 25 Aug 2014 20:31:16 +0000]
Add GetValidBpc() check in CPDF_DIBSource::GetScanLine

BUG=406600, 406895
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/497733005

5 years agoRevert of Use number of components from ICC profile and alternateCS (patchset #1...
Bo Xu [Mon, 25 Aug 2014 18:52:41 +0000]
Revert of Use number of components from ICC profile and alternateCS (patchset #1 of https://codereview.chromium.org/493163003/)

Reason for revert:
Needs to address comments before landing

Original issue's description:
> Use number of components from ICC profile and alternate color space
>
> BUG=406806
>
> Committed: https://pdfium.googlesource.com/pdfium/+/be83103

TBR=tsepez@chromium.org,jun_fang@foxitsoftware.com
NOTREECHECKS=true
NOTRY=true
BUG=406806

Review URL: https://codereview.chromium.org/504883003

5 years agoUse number of components from ICC profile and alternate color space
Bo Xu [Mon, 25 Aug 2014 17:01:19 +0000]
Use number of components from ICC profile and alternate color space

BUG=406806

Review URL: https://codereview.chromium.org/493163003

5 years agoFix the issue 'SEGV on unknown address in CPDF_DataAvail::GetObjectSize'
Jun Fang [Sat, 23 Aug 2014 00:06:32 +0000]
Fix the issue 'SEGV on unknown address in CPDF_DataAvail::GetObjectSize'

BUG=387983
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/454283002

5 years agoFix a hang issue due to inconsistent page number in the test file
Jun Fang [Sat, 23 Aug 2014 00:04:29 +0000]
Fix a hang issue due to inconsistent page number in the test file

Pdfium reads the page number from the field of '/Count' but it can't
load the number assigned by this field due to the damaged data. Add a
check to ensure that the required page should be one of loaded pages.

BUG=406090
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/477873003

5 years agoBounds check in CFX_Font::LoadGlyphPath().
Tom Sepez [Fri, 22 Aug 2014 23:07:58 +0000]
Bounds check in CFX_Font::LoadGlyphPath().

Add a check to CFX_Font::LoadGlyphPath() similar to the one that exists
in CFX_FaceCache::RenderGlyph().

Also replace some scattered magic numbers in the file with constants,
and make arrays not used outside this file be statically scoped.

BUG=406144
R=jun_fang@foxitsoftware.com

Review URL: https://codereview.chromium.org/497863002

5 years agoFix confusion between length in bytes and length in characters in app::response().
Tom Sepez [Fri, 22 Aug 2014 22:52:05 +0000]
Fix confusion between length in bytes and length in characters in app::response().

I also clean up the code while we are here, rewriting a strange switch statement and tidying whitespace.

BUG=406142
R=jun_fang@foxitsoftware.com

Review URL: https://codereview.chromium.org/498773004

5 years agoDon't stretch bitmaps if destination size is empty.
Vitaly Buka [Fri, 22 Aug 2014 21:01:56 +0000]
Don't stretch bitmaps if destination size is empty.

BUG=405201
R=bo_xu@foxitsoftware.com

Review URL: https://codereview.chromium.org/474093003

5 years agoCheck the number of component in ICCBased colorspace
Bo Xu [Fri, 22 Aug 2014 17:30:10 +0000]
Check the number of component in ICCBased colorspace

From PDF reference 8.6.5.5, this could only be 1, 3 or 4.

BUG=387968
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/464083003

5 years agoFor pattern colorspace, its base colorspace should not be a pattern colorspace
Bo Xu [Thu, 21 Aug 2014 22:19:00 +0000]
For pattern colorspace, its base colorspace should not be a pattern colorspace

BUG=405588
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/496883002

5 years agoCheck if user provided more than one option for pdfium_test.
Vitaly Buka [Wed, 20 Aug 2014 17:32:36 +0000]
Check if user provided more than one option for pdfium_test.

R=bo_xu@foxitsoftware.com

Review URL: https://codereview.chromium.org/477173003

5 years agoFix bug in CPDF_PageContentGenerate constructor and destructor
Bo Xu [Wed, 20 Aug 2014 00:17:04 +0000]
Fix bug in CPDF_PageContentGenerate constructor and destructor

m_pageObjects never gets initialize, thus making CPDF_PageContentGenerate::GenerateContent() doing nothing.

Since the CPFD_PageObject are owned by m_pPage, no need to release them in the destructor.

BUG=385119
R=thestig@chromium.org, vitalybuka@chromium.org

Review URL: https://codereview.chromium.org/470253004

5 years agoFixed command line parting when no output is needed.
Vitaly Buka [Tue, 19 Aug 2014 21:22:19 +0000]
Fixed command line parting when no output is needed.

R=bo_xu@foxitsoftware.com

Review URL: https://codereview.chromium.org/492523002

5 years agoFont is used after release in CPDF_TextStateData::~CPDF_TextStateData
Jun Fang [Mon, 18 Aug 2014 23:39:43 +0000]
Font is used after release in CPDF_TextStateData::~CPDF_TextStateData

BUG=400996
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/477323002

5 years agoFix a double-free issue in CFX_PathData::~CFX_PathData
Jun Fang [Mon, 18 Aug 2014 19:21:44 +0000]
Fix a double-free issue in CFX_PathData::~CFX_PathData

In CPDFSDK_InterForm::SubmitFields, the buffer pointed by m_pBuffer is returned
and released by the caller. However, it will be released again in the destructor.

BUG=401580
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/481733002

5 years agoCheck path point count overflow in DrawThisAppearance
Bo Xu [Mon, 18 Aug 2014 18:33:03 +0000]
Check path point count overflow in DrawThisAppearance

BUG=387969
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/461343003

5 years agoAdd a null check before getting unicode text in CPDF_FormField::GetValue
Jun Fang [Mon, 18 Aug 2014 18:30:19 +0000]
Add a null check before getting unicode text in CPDF_FormField::GetValue

The test pdf file defines an invalid dictionary object with a NULL arrary
in the filed of "/V". It causes that a NULL object is returned when trying
to get the first element of this arrary. So it needs to check whether the
returned object is NULL.

BUG=395986
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/478183002

5 years agoAdd a null pointer check before getting the family name of the given color space...
Jun Fang [Mon, 18 Aug 2014 18:27:20 +0000]
Add a null pointer check before getting the family name of the given color space in CPDF_ColorSpace::Load

The test file defines a wrong color space object (7 0 obj). In the content of 7 0 obj,
the reserved obj (0 0 R) is used. The process of loading color space returns NULL when
the reserved obj (0 0 R) is found. For the error color space, it only needs to return
NULL when an error is detected.

BUG=403032
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/477413002

5 years agoFix tzHour usage on systems where char is unsigned.
Nico Weber [Mon, 18 Aug 2014 18:17:42 +0000]
Fix tzHour usage on systems where char is unsigned.

BUG=chromium:395832
R=bo_xu@foxitsoftware.com

Review URL: https://codereview.chromium.org/478353002

5 years agoNo need to release m_pBaseCS in CPDF_IndexedCS and CPDF_PatternCS
Bo Xu [Mon, 18 Aug 2014 16:58:58 +0000]
No need to release m_pBaseCS in CPDF_IndexedCS and CPDF_PatternCS

m_pBaseCS will be released in CPDF_DocPageData::Clear.

BUG=401372
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/472653002

5 years agoFix buffer size offset error in PNG_Predictor
Bo Xu [Fri, 15 Aug 2014 19:24:45 +0000]
Fix buffer size offset error in PNG_Predictor

BUG=393602
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/466153005

5 years agoAdd FX_OVERRIDE and use it for virtual functions of FX_FINAL classes.
Tom Sepez [Thu, 14 Aug 2014 00:12:28 +0000]
Add FX_OVERRIDE and use it for virtual functions of FX_FINAL classes.

Should there be cases where this fails to compile, it indicates a mistake,
either an incorrectly declared overrriden virtual method, or a method that
should be declared non-virtual.

The only issues were with CPDF_CustomAccess::GetBlock(), CPDF_CustomAccess::GetByte(),
and CPDF_CustomAccess::GetFullPath(). These don't appear to be used anywhere,
and are removed.  Two members are removed that are no longer needed once those
methods are removed.

R=jam@chromium.org, jun_fang@foxitsoftware.com

Review URL: https://codereview.chromium.org/454983003

5 years agoDisable exceptions for the pdfium targets, now that pdfium:29 is done.
Nico Weber [Wed, 13 Aug 2014 18:12:31 +0000]
Disable exceptions for the pdfium targets, now that pdfium:29 is done.

BUG=pdfium:29
R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/470503004

5 years agoRemove try/catch block
Bo Xu [Wed, 13 Aug 2014 18:03:19 +0000]
Remove try/catch block

BUG=pdfium:28
R=thakis@chromium.org

Review URL: https://codereview.chromium.org/472563002

5 years agoTreat null Parent as no Parent for dictionary objects
Bo Xu [Tue, 12 Aug 2014 18:10:51 +0000]
Treat null Parent as no Parent for dictionary objects

To be complient with PDF reference chapter 7.3.7

BUG=402437
R=vitalybuka@chromium.org

Review URL: https://codereview.chromium.org/469573002

5 years agoFix missing or broken include guard macros in pdfium headers.
Tom Sepez [Tue, 12 Aug 2014 21:43:18 +0000]
Fix missing or broken include guard macros in pdfium headers.

This has no ill-effect at present, but may be distracting when viewing the file
since it just looks wrong.

R=jun_fang@foxitsoftware.com

Review URL: https://codereview.chromium.org/461933003

5 years agoFor a CPDF_Color object, when set a new pattern to it, disconnect its link with the...
Bo Xu [Tue, 12 Aug 2014 21:36:21 +0000]
For a CPDF_Color object, when set a new pattern to it, disconnect its link with the old pattern

This patch is related to https://pdfium.googlesource.com/pdfium/+/1b9c5c4dc41956b8c5ab17b9a882adf8a2513768

BUG=402260
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/460383004

5 years agoWhen normalize coordinate, return instead of assert() when divide by 0
Bo Xu [Fri, 8 Aug 2014 02:01:34 +0000]
When normalize coordinate, return instead of assert() when divide by 0

BUG=382988
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/433293002

5 years agoChange '>=' back to '>' in extension.h due to bad fix
Jun Fang [Thu, 7 Aug 2014 17:08:19 +0000]
Change '>=' back to '>' in extension.h due to bad fix

BUG=400662
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/445303002

5 years agogclient DEPS file for auto checking out deps
Aneesh Mulye [Thu, 7 Aug 2014 01:11:02 +0000]
gclient DEPS file for auto checking out deps

Added a DEPS file so that bot_update and gclient can automatically check
out dependencies (GYP, V8, ICU, and on Windows, Cygwin).

BUG=375773
R=jam@chromium.org, nodir@chromium.org

Review URL: https://codereview.chromium.org/416663002

5 years agoClean up meaningless branch on commented-out code.
Chris Palmer [Wed, 6 Aug 2014 21:17:45 +0000]
Clean up meaningless branch on commented-out code.

BUG=https://code.google.com/p/pdfium/issues/detail?id=35
R=bo_xu@foxitsoftware.com

Review URL: https://codereview.chromium.org/451483003

5 years agoFix the problem that memory is accessed after released due to invalid type-cast
Jun Fang [Tue, 5 Aug 2014 11:32:48 +0000]
Fix the problem that memory is accessed after released due to invalid type-cast

BUG=387774
R=palmer@chromium.org, tsepez@chromium.org

Review URL: https://codereview.chromium.org/441503003

5 years agoThe root cause of this issue is shown as below:
Jun Fang [Tue, 5 Aug 2014 09:38:22 +0000]
The root cause of this issue is shown as below:
Patterns are managed in CPDF_DocPageData. When
a document is closed, all patterns will be
released in the deconstruction of CPDF_DocPageData.
However, some patterns which are referenced in
CPDF_Color can't get the notification from the
destroy of CPDF_DocPageData. It will cause
use-after-free in CPDF_Color::~CPDF_Color.

BUG=392719
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/439693002

5 years agoFix unninitialized 'tmp' in CJBig2_Image::composeTo_opt2
Jun Fang [Tue, 5 Aug 2014 02:25:14 +0000]
Fix unninitialized 'tmp' in CJBig2_Image::composeTo_opt2

BUG=387811
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/437483004

5 years agoRemove unused |m_pEvi| field.
Chris Palmer [Mon, 4 Aug 2014 22:58:07 +0000]
Remove unused |m_pEvi| field.

Edge closer to the goal of building PDFium with the chromium_code
configuration.

BUG=https://code.google.com/p/pdfium/issues/detail?id=29
R=bo_xu@foxitsoftware.com, thakis@chromium.org

Review URL: https://codereview.chromium.org/441763002

5 years agoFix a segmentation fault in CPDF_DataAvail::CheckPage due to invalid usage of i++
Jun Fang [Mon, 4 Aug 2014 19:58:19 +0000]
Fix a segmentation fault in CPDF_DataAvail::CheckPage due to invalid usage of i++

BUG=387979
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/439733002

5 years agoFix buffer size boundary check offset by 1
Bo Xu [Sat, 2 Aug 2014 22:13:46 +0000]
Fix buffer size boundary check offset by 1

When newPos == file size, the current block will not be read or Get. If this block is a crucial part of the document (like m_pTrailer), the program will exit with parse error and
the document will not be rendered.

BUG=None
R=jun_fang@foxitsoftware.com

Review URL: https://codereview.chromium.org/440563003

5 years agoAdd more |bpc| value check in GetValidBpc()
Bo Xu [Fri, 1 Aug 2014 23:14:27 +0000]
Add more |bpc| value check in GetValidBpc()

BUG=382988
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/430733004

5 years agoFix for min/max compile error on Windows
Scott Graham [Fri, 1 Aug 2014 05:12:25 +0000]
Fix for min/max compile error on Windows

Patch from jschuh@chromium.org.

BUG=pdfium:31
TBR=jschuh@chromium.org,thakis@chromium.org

Review URL: https://codereview.chromium.org/438843003

5 years agoRevert 'gn: cross-platform exception disable'
Scott Graham [Fri, 1 Aug 2014 00:23:24 +0000]
Revert 'gn: cross-platform exception disable'

This reverts commit 4923e3cfbc2b617614858c427fa87a8c67aca784.

Since exceptions are in the process of being removed,
and the code currently isn't rollable into pdfium (for other
reasons) I'm going to revert this for now, so that this CL
doesn't become blocking-for-rolls if the other min/max problem
is addressed.

And, hopefully by the time I get back to this it won't be
necessary anyway.

BUG=pdfium:28,pdfium:31,chromium:354261
R=thakis@chromium.org

Review URL: https://codereview.chromium.org/432243002

5 years agogn: cross-platform exception disable
Scott Graham [Thu, 31 Jul 2014 22:17:36 +0000]
gn: cross-platform exception disable

Goes with https://codereview.chromium.org/431803003/

R=jam@chromium.org
BUG=chromium:354261

Review URL: https://codereview.chromium.org/426153007

5 years agoremove .gitattributes to prevent automatic CRLF conversions
Scott Graham [Thu, 31 Jul 2014 22:16:30 +0000]
remove .gitattributes to prevent automatic CRLF conversions

Added by https://codereview.chromium.org/292313014/ but causes
annoying warnings on Windows. Just don't add CRLFs.

R=jam@chromium.org

Review URL: https://codereview.chromium.org/430043002

5 years agoCorrect the names of the FX_SAFE_* typedefs.
Chris Palmer [Thu, 31 Jul 2014 19:08:56 +0000]
Correct the names of the FX_SAFE_* typedefs.

R=jun_fang@foxitsoftware.com

Review URL: https://codereview.chromium.org/417263008

5 years agoFix a few more -Wreorder warnings.
Nico Weber [Thu, 31 Jul 2014 17:07:04 +0000]
Fix a few more -Wreorder warnings.

No intended behavior change.

BUG=pdfium:29
R=bo_xu@foxitsoftware.com

Review URL: https://codereview.chromium.org/436483002

5 years agoRemove CPDFSDK_Annot::ResetAppearance().
Nico Weber [Thu, 31 Jul 2014 17:00:12 +0000]
Remove CPDFSDK_Annot::ResetAppearance().

It's unused, and it caused a warning about CPDFSDK_Widget::ResetAppearance()
failing to override it (since these two unrelated methods had the same name).

No intended behavior change.

BUG=pdfium:29
R=bo_xu@foxitsoftware.com

Review URL: https://codereview.chromium.org/429483004

5 years agoFix integer overflow when stretch bitmap
Bo Xu [Thu, 31 Jul 2014 16:55:36 +0000]
Fix integer overflow when stretch bitmap

When an image object is zoomed in by a big factor, the scaling factor in the transformation matrix is big as well, resulting in a large |dest_width| and |dest_height| value(they can be think of as the equivalent pixel size of the entire image, although most of it is outside the device).

BUG=395636
R=vitalybuka@chromium.org

Review URL: https://codereview.chromium.org/432543002

5 years agoFix uninitialized coords and one of infinite loops
JUN FANG [Thu, 31 Jul 2014 06:12:56 +0000]
Fix uninitialized coords and one of infinite loops

BUG=387854
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/372453005

5 years agoRemove a few unused variables, functions, and member variables.
Nico Weber [Thu, 31 Jul 2014 02:00:31 +0000]
Remove a few unused variables, functions, and member variables.

No intended behavior change.

BUG=pdfium:29
R=bo_xu@foxitsoftware.com

Review URL: https://codereview.chromium.org/426763003

5 years agoFix a few -Wreorder warnings.
Nico Weber [Thu, 31 Jul 2014 01:59:57 +0000]
Fix a few -Wreorder warnings.

BUG=pdfium:29
R=bo_xu@foxitsoftware.com

Review URL: https://codereview.chromium.org/427353003

5 years agoAdd missing braces for aggregate initializers.
Nico Weber [Thu, 31 Jul 2014 01:59:36 +0000]
Add missing braces for aggregate initializers.

No intended behavior change.

BUG=pdfium:29
R=bo_xu@foxitsoftware.com

Review URL: https://codereview.chromium.org/426763004

5 years agoFix potential integer overflow in fpdf_render_loadimage.cpp
JUN FANG [Wed, 30 Jul 2014 22:45:33 +0000]
Fix potential integer overflow in fpdf_render_loadimage.cpp

BUG=391929
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/419693003

5 years agoAttempt to fix some -Woverloaded-virtual warnings.
Nico Weber [Wed, 30 Jul 2014 21:17:19 +0000]
Attempt to fix some -Woverloaded-virtual warnings.

There are many warnings that look like:

error: 'CPWL_RadioButton::OnChar' hides overloaded virtual function [-Werror,-Woverloaded-virtual]
        virtual FX_BOOL                         OnChar(FX_WORD nChar);
                                                ^
note: hidden overloaded virtual function 'CPWL_Wnd::OnChar' declared here: different number of parameters (2 vs 1)
        virtual FX_BOOL                                 OnChar(FX_WORD nChar, FX_DWORD nFlag);
                                                        ^

It looks like someone added the nFlag parameter to the methods in CPWL_Wnd
at some point and missed to update all overloads This patch attempts to fix this:
It adds the parameter to all methods that look like they're trying to overload the base
class method, and renames the method in one case where it fairly clearly looks like
that it's not supposed to be an overload.

BUG=pdfium:29
R=bo_xu@foxitsoftware.com

Review URL: https://codereview.chromium.org/416383004

5 years agoFix incorrect override of GetLayoutOrder().
Nico Weber [Wed, 30 Jul 2014 21:16:25 +0000]
Fix incorrect override of GetLayoutOrder().

fsdk_baseform.h:63:19: error: 'CPDFSDK_Widget::GetLayoutOrder' hides overloaded virtual function [-Werror,-Woverloaded-virtual]
        virtual int                                             GetLayoutOrder() {return 2;}
                                                                ^
fsdk_baseannot.h:70:18: note: hidden overloaded virtual function 'CPDFSDK_Annot::GetLayoutOrder' declared here: different qualifiers (const vs none)
        virtual int                                     GetLayoutOrder() const { return 5; }
                                                        ^

On Windows, I believe MSVS treats these as override since it's such a common and
easy mistake, but clang and gcc do what the standard specifies. Add a "const" to
the function in the subclass so that this is actually an override, as intended.

BUG=pdfium:29
R=bo_xu@foxitsoftware.com

Review URL: https://codereview.chromium.org/427173002

5 years agoFix the potential integer overflow from 'offset+size' in extension.h and fpdfview.cpp
JUN FANG [Wed, 30 Jul 2014 20:46:39 +0000]
Fix the potential integer overflow from 'offset+size' in extension.h and fpdfview.cpp

BUG=397258
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/419063002

5 years agoSpeculative fix for uninitialized value in CFX_ByteString().
Tom Sepez [Wed, 30 Jul 2014 20:03:52 +0000]
Speculative fix for uninitialized value in CFX_ByteString().

If somehow different length values could be obtained by two successive calls
to Doc_getFilePath() (and FieldBrowse() for that matter), and the method is
true to the API documentation that says "The return value always indicated
number of bytes required for the buffer, even when there is no buffer
specified, or the buffer size is less then required", then it is possible
to get a returned length describing memory beyond the current buffer.

We can make the corresponding JS_docGetFilePath() method more robust against
this case by applying better checks to the returned value.

This probably is unrelated since ASAN seems to be flagging the corresponding bug
as UAF, but doesn't hurt to make things more robust.

BUG=392956
R=jun_fang@foxitsoftware.com

Review URL: https://codereview.chromium.org/423233002

5 years agoFix the typo of "Resources" keyword
Bo Xu [Tue, 29 Jul 2014 13:38:16 +0000]
Fix the typo of "Resources" keyword

BUG=None
R=thestig@chromium.org

Review URL: https://codereview.chromium.org/420793004

5 years agoTidy up app::response().
Tom Sepez [Tue, 29 Jul 2014 21:01:21 +0000]
Tidy up app::response().

Follow-up from https://codereview.chromium.org/424883002/

- Remove some stray whitespace.
- Fix "else after return".
- Remove unused swResponse local.
- Treat unexpectedly large responses as errors.

BUG=
R=jun_fang@foxitsoftware.com

Review URL: https://codereview.chromium.org/423953002

5 years agoFix a few more warnings in chromium_code mode.
Nico Weber [Tue, 29 Jul 2014 17:13:17 +0000]
Fix a few more warnings in chromium_code mode.

No intended behavior change.

- Remove more unused variables, functions, member variables.
- Put a few constructor initializers in the order they execute in.
- Add braces for subobject initializers.
- Fix a handful of signed / unsigned comparisons.

BUG=pdfium:29
R=bo_xu@foxitsoftware.com

Review URL: https://codereview.chromium.org/429593005

5 years agoRemove a few unused variables, functions, and tables.
Nico Weber [Tue, 29 Jul 2014 15:55:54 +0000]
Remove a few unused variables, functions, and tables.

Found by clang's -Wunused-variable, -Wunused-function, -Wunused-const-variable.

BUG=none
R=bo_xu@foxitsoftware.com

Review URL: https://codereview.chromium.org/404653005

5 years agoRemove 'inline' from two methods.
Nico Weber [Mon, 28 Jul 2014 22:23:04 +0000]
Remove 'inline' from two methods.

The methods are only defined in the cpp and thus can't always be inlined,
the methods are virtual and so can only be inlined when the concrete type
is known, and inline functions need their definition available in all
translation units.

So just remove the 'inline'.

BUG=none
R=bo_xu@foxitsoftware.com

Review URL: https://codereview.chromium.org/409253004

5 years agoCalRGB color correction
Bo Xu [Fri, 25 Jul 2014 00:50:59 +0000]
CalRGB color correction

BUG=pdfium:19
R=thestig@chromium.org

Review URL: https://codereview.chromium.org/403163002