Overwriting document with itself breaks document

Bug #1133257 reported by Benjamin Eltzner
16
This bug affects 2 people
Affects Status Importance Assigned to Milestone
qpdfview
Fix Released
Critical
Adam Reichold
qpdfview (Ubuntu)
Fix Released
Undecided
Benjamin Eltzner

Bug Description

Steps to reproduce:
1. Open some test.pdf or test.ps (or better a security copy of it) in qpdfview.
2. Choose "save copy" or "save as" from the menu (or by shortcut) and save the file with unchanged name, confirm to overwrite.
3. If you chose "save as", qpdfview will immediately try to load the saved file, fail, pop up an error message and keep the cached file in the tab. The file on disk is now 0 bytes in size and void of content.

I have not tested this with DjVu, but as behaviour for ps and pdf is identical, I assume this bug is in qpdfview.

Using:
Ubuntu 12.04 (Precise)
Poppler 0.18.4
libspectre 0.2.6
qpdfview 0.4.0.99~995~37~precise1 (current dailydeb)

It would be good if someone tested this with the 0.3.7 (the one to be in Ubuntu 13.04) and 0.4 releases, because if the bug is present there, it should urgently be fixed as it potentially deletes files unexpectedly and without backup. (I therefore take the liberty to claim the bug priority "critical".)

Tags: patch
description: updated
Revision history for this message
Adam Reichold (adamreichold) wrote :

I am not sure I agree with the "critical" nomination since this is well-known behavior. One could argue that it is badly documented, but that is a different question.

Revision history for this message
Adam Reichold (adamreichold) wrote :

And concerning the question about version 0.3.7, its behavior and that of the versions before is definitely the same.

Revision history for this message
Adam Reichold (adamreichold) wrote :

I committed a change that prevents the user from trying to overwrite a file with itself. See the diff from trunk revision 995 to 996 for a patch that could be included in packages.

Changed in qpdfview:
assignee: nobody → Adam Reichold (adamreichold)
milestone: none → 0.4.1
status: New → Fix Committed
Revision history for this message
Benjamin Eltzner (b-eltzner) wrote :

Thanks for changing this feature.

Changed in qpdfview:
importance: Critical → Wishlist
Revision history for this message
Adam Reichold (adamreichold) wrote :

It's a bug, not a feature. Anyway, in trunk revision 1002, I implemented the usual workaround to write the data into a temporary file first and copy it to the original destination afterwards.

However, this does not lend itself to backporting before 0.4 because it needs to Model::Document::save method. It also feels more fragile to me than just outright refusing to do the operation, so a lot of testing seems advisable.

Changed in qpdfview:
importance: Wishlist → Critical
Revision history for this message
Benjamin Eltzner (b-eltzner) wrote :

I did some testing and also tried using symlinks and cups-pdf to break stuff. So far everything seems to work well. Thank you for the additional change. I updated the current packages (for 0.4) with the warning message.

Changed in qpdfview:
status: Fix Committed → Fix Released
Changed in qpdfview (Ubuntu):
status: New → Confirmed
Revision history for this message
Benjamin Eltzner (b-eltzner) wrote :

I attach a patch that provides a simple solution to this problem, because the bug affects the version of qpdfview in Ubuntu 13.04.

Changed in qpdfview (Ubuntu):
assignee: nobody → Benjamin Eltzner (b-eltzner)
Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "save.patch" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
Revision history for this message
Benjamin Eltzner (b-eltzner) wrote :

This bug affected the package in Raring and is fixed in later versions. As Raring has reached EOL some months ago, this bug is obsolete und no longer needs tracking.

Changed in qpdfview (Ubuntu):
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.