Hi folks

I'm out of time, so I'm dropping this note here to make sure it doesn't 
get lost.

There's an issue - triggered by running ContentsParser on the sample PDF 
Dave Sangrad sent to the list under both Win32 and Linux (with and w/o 
valgrind) where PdfContentsReader tries to read uninitialized memory off 
the end of its stored PdfRefCountedBuffer . It looks like 
PdfBufferOutputStream::Write(...) is getting the right data when 
receiving data to store in the stream - in this case from a deflate 
filter on PdfStream - but something is going wrong after that.

What it turns out to be is that PdfRefCountedBuffer isn't keeping track 
of the fact that the "visible size" separately from its own internally 
allocated buffer size. It's overallocating (like it should) but when it 
does so, it's reporting the over-allocated size to the user rather than 
using it invisibly and internally to provide faster Resize() operations 
like it should.

Other code, like PdfTokenizer::GetNextToken(), is assuming that the 
GetSize() from the buffer returns the "visible" size, and relying on 
that. Consequently, when used on a content stream (which has no natural 
"end" delimiter like a PDF object does) we read off the end of the 
buffer and into uninitialized but allocated memory. Splat.

I've adjusted PdfRefCountedBuffer to track the user visible size of the 
PdfRefCountedBuffer separately to the real size of the backing piece of 
memory. This does need more testing, though it passes the basic tests. 
It's super late and I have to work tomorrow, though, so yell at me, 
revert r718, or whatever if I've missed something.

--
Craig Ringer

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Podofo-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/podofo-users

Reply via email to