PoDoFo 0.9.5 function TextExtractor::ExtractText in TextExtractor.cpp:77 cause a NULL pointer dereference
Analyzer
code from https://sourceforge.net/p/podofo/code/HEAD/tree/podofo/trunk/ (2017-04-09)
compile:
1 | cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/home/icepng/aaaa/ -DCMAKE_BUILD_TYPE=DEBUG -DCMAKE_EXE_LINKER_FLAGS="-fsanitize=address -fno-omit-frame-pointer" ../ |
and run it:
1 | ./podofo-code/podofo/trunk/build/tools/podofotxtextract/podofotxtextract ./PoC |
Crash Info
1 | ================================================================= |
analysis
and the Process is easy, When use podofotxtextract to extract txt info from a pdf file, first extract the input file to a PdfMemDocument object, and then let each page to a PdfContentsTokenizer object, which contained many tokens, and last deal each token.
1 | if( eType == ePdfContentsType_Keyword ) |
I set the breakpoints and I found there had 45 ePdfContentsType_Variant but 23 MoveTo Tokens.
so stack.top() will be NULL in “dCurPosY = stack.top().GetReal();”, then cause a NULL point dereference.
So the upstream don’t give strict check about Path Construction Operators “MoveTo”.