Commit b0a96ce6aa95c4d23e40eed3cede2f46e935bba7

Authored by Jay Berkenbilt
1 parent 247d70ef

Fix calculation of xref stream stream columns

Fix problem: if the last object in the first part of a linearized file
had an offset that was below 65536 by less than the size of the hint
stream, the xref stream was invalid and the resulting file is not
usable.
ChangeLog
  1 +2014-02-22 Jay Berkenbilt <ejb@ql.org>
  2 +
  3 + * Bug fix: if the last object in the first part of a linearized
  4 + file had an offset that was below 65536 by less than the size of
  5 + the hint stream, the xref stream was invalid and the resulting file
  6 + is not usable. This is now fixed.
  7 +
1 8 2014-01-14 Jay Berkenbilt <ejb@ql.org>
2 9  
3 10 * 5.1.1: release
... ...
libqpdf/QPDFWriter.cc
... ... @@ -2447,7 +2447,7 @@ QPDFWriter::writeXRefStream(int xref_id, int max_id, qpdf_offset_t max_offset,
2447 2447 qpdf_offset_t space_before_zero = xref_offset - 1;
2448 2448  
2449 2449 // field 1 contains offsets and object stream identifiers
2450   - int f1_size = std::max(bytesNeeded(max_offset),
  2450 + int f1_size = std::max(bytesNeeded(max_offset + hint_length),
2451 2451 bytesNeeded(max_id));
2452 2452  
2453 2453 // field 2 contains object stream indices
... ...