pdfium.git
4 years agoRename functions in test code also -- fixing build-break from 2c021e0
Bo Xu [Mon, 17 Nov 2014 00:46:31 +0000]
Rename functions in test code also -- fixing build-break from 2c021e0

Change 2c021e0 fixed spelling errors in a couple of functions, but didn't
update the test code leading to two compilation errors. Fixed in this
change.

Original patch from Bruce Dawson(brucedawson@chromium.org)

R=bo_xu@foxitsoftware.com

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

4 years agoCorrect typo in form fill environment functions
Bo Xu [Sat, 15 Nov 2014 01:40:50 +0000]
Correct typo in form fill environment functions

Complementary patch in chromium is in https://codereview.chromium.org/711553003

R=thestig@chromium.org

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

4 years agoRemove FX_LPCWSTR cast to wchar_t* literals
Bo Xu [Sat, 15 Nov 2014 01:03:50 +0000]
Remove FX_LPCWSTR cast to wchar_t* literals

BUG=https://code.google.com/p/pdfium/issues/detail?id=78
R=tsepez@chromium.org

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

4 years agoChange from 'this' to L'this' and remove the cast that was hiding this mismatch.
Bo Xu [Fri, 14 Nov 2014 22:18:05 +0000]
Change from 'this' to L'this' and remove the cast that was hiding this mismatch.

Found by VC++'s /analyze. Warning was:

fpdfsdk\src\javascript\js_runtime.cpp(352) : warning C6276:
Cast between semantically different string types:  char * to wchar_t *.
Use of invalid string can lead to undefined behavior.

This mismatch has been there as far back as the history goes (to May of this year).

It looks like a real bug to me. However I don't know the implications of this bug and why it would not have been noticed at run-time.

The code has been this way as far back as the git history goes, but that is only to May 2014.

Original patch from Bruce Dawson(brucedawson@chromium.org)

BUG=427616
R=bo_xu@foxitsoftware.com

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

4 years agoFix build warning on android under stricter compilation rules.
Tom Sepez [Fri, 14 Nov 2014 19:29:28 +0000]
Fix build warning on android under stricter compilation rules.

Error is "converting to non-pointer type 'FX_DWORD'".
TBR=bo_xu@foxitsoftware.com

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

4 years agoBuild pdfium_test executable under GN.
Tom Sepez [Fri, 14 Nov 2014 00:59:03 +0000]
Build pdfium_test executable under GN.

This is the first side of a two-sided patch;
the dependency on //third_party/pdfium/samples will be included from //pdf/BUILD.gn in the chrome repo.

BUG=https://code.google.com/p/pdfium/issues/detail?id=77
R=dpranke@chromium.org

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

4 years agoMake DEPS use relative paths to fix recipe
Aneesh Mulye [Thu, 13 Nov 2014 21:59:20 +0000]
Make DEPS use relative paths to fix recipe

Context: DEPS was originally added to pdfium to allow its recipe to
automatically check out its dependencies. The recipe used absolute
paths, and so the checkout directory's name ('pdfium') had to be
prefixed to the directory checkout of every dependency, as gclient in
the recipe worked one level above the pdfium checkout itself.

After change fe4537269fc7133320a5131638757f2ffa6bd854, the recipe no
longer worked. To fix this, I'm making DEPS use relative paths.

BUG=375773
R=jam@chromium.org

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

4 years agoFix a bug when performing StretchDIBits on bit mask
Bo Xu [Mon, 10 Nov 2014 21:34:05 +0000]
Fix a bug when performing StretchDIBits on bit mask

BUG=401988
R=vitalybuka@chromium.org

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

4 years agoFix bug with reading from uninitialized variable found by VC++'s /analyze.
Tom Sepez [Thu, 6 Nov 2014 23:00:36 +0000]
Fix bug with reading from uninitialized variable found by VC++'s /analyze.

The flag variable is conditionally initialized but unconditionally read.

Warning was:
src\fpdfapi\fpdf_page\fpdf_page_pattern.cpp(274) : warning C6001:
Using uninitialized memory 'flag'.

BUG=427616
R=tsepez@chromium.org

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

4 years agoAdding constructor to _FX_SYSTEMTIME to resolve uninitialized read bugs found by...
Tom Sepez [Thu, 6 Nov 2014 22:38:12 +0000]
Adding constructor to _FX_SYSTEMTIME to resolve uninitialized read bugs found by /analyze on some error paths

Warning from /analyze was:
src\third_party\pdfium\fpdfsdk\include\fsdk_mgr.h(96) : warning C6001: Using uninitialized memory 'fxtime'.

Other error paths can also lead to reading from an uninitialized _FX_SYSTEMTIME object.

Code-gen for the constructor is small enough (four writes of zeroed EAX with VC++, less with gcc) to make putting the constructor in a .cc file unnecessary.

Approval of in-class member initialization would make this fix simpler but that has not quite been approved yet.

BUG=https://code.google.com/p/pdfium/issues/detail?id=70
BUG=427616
R=tsepez@chromium.org

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

4 years agoFix PDFium build with Windows GN.
John Abd-El-Malek [Thu, 6 Nov 2014 18:42:39 +0000]
Fix PDFium build with Windows GN.

R=scottmg@chromium.org

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

4 years agoUndo an old change in freetype to account for size of USHORT
Bo Xu [Thu, 30 Oct 2014 23:02:56 +0000]
Undo an old change in freetype to account for size of USHORT

BUG=418582
R=tsepez@chromium.org

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

4 years agoFor v8 Global Object, do not copy in CJS_Value constructor.
Tom Sepez [Thu, 30 Oct 2014 20:23:42 +0000]
For v8 Global Object, do not copy in CJS_Value constructor.

BUG=425129
R=bo_xu@foxitsoftware.com

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

4 years agoUpdate openjpeg to r2920
Bo Xu [Thu, 30 Oct 2014 20:10:50 +0000]
Update openjpeg to r2920

BUG=414036, 425151
R=tsepez@chromium.org

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

4 years agoResolve compilation error with G++ 4.9.
Tom Sepez [Wed, 29 Oct 2014 22:31:20 +0000]
Resolve compilation error with G++ 4.9.

Add a check for zero-length keys to avoid hitting the equivalent of |""[1]|.
BUG=https://code.google.com/p/pdfium/issues/detail?id=58
R=jun_fang@foxitsoftware.com

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

4 years agoupdate openjpeg to r2911
Bo Xu [Wed, 22 Oct 2014 22:32:43 +0000]
update openjpeg to r2911

BUG=418976, 425150, 414525
R=tsepez@chromium.org

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

4 years agoChange the clear order of pDocPage and pDocRender
Bo Xu [Tue, 21 Oct 2014 21:50:16 +0000]
Change the clear order of pDocPage and pDocRender

pTransfer function is released in pDocRender cleanup but is still being accessed in
~CPDF_GeneralStateData in pDocPage cleanup.

BUG=419320
R=tsepez@chromium.org

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

4 years agoUpdate openjpeg to r2908
Bo Xu [Tue, 21 Oct 2014 20:05:17 +0000]
Update openjpeg to r2908

BUG=414089, 414310, 414606
R=tsepez@chromium.org

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

4 years agoMore fixes in sycc422_to_rgb and sycc420_to_rgb when image width is odd
Bo Xu [Tue, 21 Oct 2014 19:17:39 +0000]
More fixes in sycc422_to_rgb and sycc420_to_rgb when image width is odd

This patch is supplementary to issue 418881

R=tsepez@chromium.org

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

4 years agoAdd missing parenthesis in FXARGB_GETDIB macro
Bo Xu [Tue, 21 Oct 2014 19:04:41 +0000]
Add missing parenthesis in FXARGB_GETDIB macro

You can get warning when using FXARGB_GETDIB() with & operation in
the same statement like: FXARGB_GETDIB(src_scan) & 0xffffff in
fx_dib_composite.cpp:

../../third_party/pdfium/core/src/fxge/dib/fx_dib_composite.cpp:737:205:
error: '&' within '|' [-Werror,-Wbitwise-op-parentheses]

Original patch from jiangj@opera.com

R=thakis@chromium.org

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

4 years agoMake DEPS not add an extra pdfium directory.
John Abd-El-Malek [Thu, 16 Oct 2014 22:32:26 +0000]
Make DEPS not add an extra pdfium directory.

This makes gclient config and gclient sync work.

BUG=423896
TBR=aneeshm@chromium.org

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

4 years agoFix standalone build on Linux and Mac.
John Abd-El-Malek [Thu, 16 Oct 2014 21:26:18 +0000]
Fix standalone build on Linux and Mac.

BUG=423883
R=scottmg@chromium.org

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

4 years agoFix licenses in headers to pass Chromium's checklicenses tool.
Tom Sepez [Wed, 15 Oct 2014 17:16:45 +0000]
Fix licenses in headers to pass Chromium's checklicenses tool.

This is a re-landing of the changes in https://pdfium.googlesource.com/pdfium/+/6387aff
which were lost during a libopenjpeg library roll.

TBR=thestig@chromium.org

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

4 years agoStore the address of the page data map's value for proper referencing.
Bo Xu [Wed, 15 Oct 2014 00:10:06 +0000]
Store the address of the page data map's value for proper referencing.

CPDF_Pattern objects are counted and maintained in m_PatternedMap.
When a CPDF_Pattern object "pattern" is deleted, it's address is marked as NULL in m_PatternMap.
This patch stores the address of CPDF_Pattern's adderss in all objects that references "pattern",
to ensure valid referencing after deletion.

BUG=416319, 419976, 418392
R=tsepez@chromium.org

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

4 years agoDon't leave dangling pointer to out-of-scope local in CPDF_StreamContentParser::Parse.
Tom Sepez [Tue, 14 Oct 2014 21:40:57 +0000]
Don't leave dangling pointer to out-of-scope local in CPDF_StreamContentParser::Parse.

This is just a bit of defensive programming; I'm not sure the situation can
occur in the current code, but the following code is likely to set off a red
flag to anyone who reads it:
    CPDF_StreamParser syntax(pData, dwSize);
    m_pSyntax = &syntax;
since the extent of the local |syntax| is far less than the pointer member
|m_pSyntax|.  NULL it out before syntax goes out of scope.

R=jun_fang@foxitsoftware.com

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

4 years agoGlyph index is out of range in cff_get_glyph_name.
Jun Fang [Tue, 14 Oct 2014 20:57:19 +0000]
Glyph index is out of range in cff_get_glyph_name.
Glyph index shall be less than number of glyphs.

BUG=418585
R=tsepez@chromium.org

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

4 years agoFix off-by-one in sizing of m_EmbeddedToUnicodes.
Tom Sepez [Mon, 13 Oct 2014 20:16:32 +0000]
Fix off-by-one in sizing of m_EmbeddedToUnicodes.

BUG=421196
R=bo_xu@foxitsoftware.com

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

4 years agoFix a bug when image width is odd in sycc422_to_rgb
Bo Xu [Fri, 10 Oct 2014 22:57:36 +0000]
Fix a bug when image width is odd in sycc422_to_rgb

BUG=418881
R=tsepez@chromium.org

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

4 years agoEnable C linkage in fpdfppo.h
Bo Xu [Fri, 3 Oct 2014 20:18:55 +0000]
Enable C linkage in fpdfppo.h

BUG=pdfium-52
R=jun_fang@foxitsoftware.com

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

4 years agocheck pointer overflow in t2.c
Bo Xu [Fri, 3 Oct 2014 19:29:54 +0000]
check pointer overflow in t2.c

BUG=413375
R=tsepez@chromium.org

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

4 years agoAdd openjpeg pre-processor OPJ_STATIC to pdfium.gyp
Bo Xu [Fri, 3 Oct 2014 18:06:35 +0000]
Add openjpeg pre-processor OPJ_STATIC to pdfium.gyp

Openjpeg removed the definition of OPJ_STATIC in openjpeg.h.
This change is merged in https://pdfium.googlesource.com/pdfium/+/d53e6fdb0a86ca1ddb12876a60f7f2d7508b5349
So need to add OPJ_STATIC to pdfium.gyp

BUG=None
R=tsepez@chromium.org

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

4 years agoUpdate openjpeg
Bo Xu [Tue, 30 Sep 2014 18:12:05 +0000]
Update openjpeg

BUG=407964, 414182, 413447
R=tsepez@chromium.org

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

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