Commit 38c9ed23c3d05c6c217db287ae15c97498a69dd7

Authored by Jay Berkenbilt
1 parent 6c89d4b3

Treat content stream parsing errors as an error, not a warning

If parsing content streams is treated as a warning, there is no way
for a caller to know if a parsing operation has failed. This is very
dangerous and will likely result in data loss when token filters are
parser callbacks are in use.
libqpdf/QPDFObjectHandle.cc
@@ -1290,10 +1290,9 @@ QPDFObjectHandle::pipeContentStreams( @@ -1290,10 +1290,9 @@ QPDFObjectHandle::pipeContentStreams(
1290 if (! stream.pipeStreamData(p, 0, qpdf_dl_specialized)) 1290 if (! stream.pipeStreamData(p, 0, qpdf_dl_specialized))
1291 { 1291 {
1292 QTC::TC("qpdf", "QPDFObjectHandle errors in parsecontent"); 1292 QTC::TC("qpdf", "QPDFObjectHandle errors in parsecontent");
1293 - warn(stream.getOwningQPDF(),  
1294 - QPDFExc(qpdf_e_damaged_pdf, "content stream",  
1295 - description, 0,  
1296 - "errors while decoding content stream")); 1293 + throw QPDFExc(qpdf_e_damaged_pdf, "content stream",
  1294 + description, 0,
  1295 + "errors while decoding content stream");
1297 } 1296 }
1298 } 1297 }
1299 } 1298 }
qpdf/qtest/qpdf/split-content-stream-errors.out
@@ -6,4 +6,4 @@ WARNING: split-content-stream-errors.pdf (offset 557): error decoding stream dat @@ -6,4 +6,4 @@ WARNING: split-content-stream-errors.pdf (offset 557): error decoding stream dat
6 WARNING: split-content-stream-errors.pdf (offset 557): stream will be re-processed without filtering to avoid data loss 6 WARNING: split-content-stream-errors.pdf (offset 557): stream will be re-processed without filtering to avoid data loss
7 WARNING: page object 3 0 (item index 0 (from 0)): ignoring non-stream in an array of streams 7 WARNING: page object 3 0 (item index 0 (from 0)): ignoring non-stream in an array of streams
8 WARNING: split-content-stream-errors.pdf (offset 557): error decoding stream data for object 6 0: LZWDecoder: bad code received 8 WARNING: split-content-stream-errors.pdf (offset 557): error decoding stream data for object 6 0: LZWDecoder: bad code received
9 -WARNING: content stream (content stream object 6 0): errors while decoding content stream 9 +page 1: content stream (content stream object 6 0): errors while decoding content stream