Package: pdftk
Version: 2.01-1
Severity: normal

When replacing a file attachment with another of the same name, and
then extracting attachments, an earlier version of the attachment may
be produced.

To reproduce the problem, put foo.sh and bar0.pdf in a temporary
directory and run foo.sh:

    $./foo.sh
    attachment v. 1

It should have printed:

    attachment v. 2

This anomaly appears to be sensitive to initial conditions.  For
example, changing the length of the attachment's filename can yield
different results.

The size of the PDF file grows with each re-attachment of the
same-named file:

    $ ls bar*.pdf
    -rw--w----  1 wayne wayne  836 Oct 29 09:49 bar0.pdf
    -rw-rw-r--  1 wayne wayne 1345 Oct 29 13:02 bar1.pdf
    -rw-rw-r--  1 wayne wayne 1670 Oct 29 13:02 bar2.pdf

It is expected that the PDF grew from bar0.pdf to bar1.pdf--that's
when the attachment was initially added.  However, the growth from
bar1.pdf to bar2.pdf, when the attachment was re-added with new,
same-size contents, is unexpected.

It is acting as though:

* An attachment is not replacing an attachment of the same name, but
  instead is being added as a new attachment with the same name, and
* When multiple attachments of the same name exist, one of them is
  extracted; it may, or may not be, the most recent one added.

I do not claim, of course, that this is what is actually happening.
This is just one model that explains this behavior.

#!/bin/sh

echo 'attachment v. 1' >foo
pdftk bar0.pdf attach_files foo output bar1.pdf

echo 'attachment v. 2' >foo
pdftk bar1.pdf attach_files foo output bar2.pdf

rm foo
pdftk bar2.pdf unpack_files output .
cat foo    # Should print "attachment v. 2"

-- System Information:
Debian Release: jessie/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: i386 (i686)

Kernel: Linux 2.6.38-2-686-bigmem (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages pdftk depends on:
ii  libc6       2.17-93
ii  libgcc1     1:4.8.1-10
ii  libgcj14    4.8.1-10
ii  libstdc++6  4.8.1-10

pdftk recommends no packages.

Versions of packages pdftk suggests:
ii  poppler-utils [xpdf-utils]  0.18.4-8

-- no debconf information

Attachment: bar0.pdf
Description: Adobe PDF document

Reply via email to