GNU bug report logs - #5313
editing files in hexl-mode corrupts file

Previous Next

Package: emacs;

Reported by: Jonathan Underwood <jonathan.underwood <at> gmail.com>

Date: Tue, 5 Jan 2010 14:09:08 UTC

Severity: normal

Done: Juanma Barranquero <lekktu <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 5313 in the body.
You can then email your comments to 5313 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5313; Package emacs. (Tue, 05 Jan 2010 14:09:08 GMT) Full text and rfc822 format available.

Acknowledgement sent to Jonathan Underwood <jonathan.underwood <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 05 Jan 2010 14:09:08 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Jonathan Underwood <jonathan.underwood <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: editing files in hexl-mode corrupts file
Date: Mon, 4 Jan 2010 13:35:46 +0000
A bug report was filed downstream about hexl-mode corrupting a file
during editing:

https://bugzilla.redhat.com/show_bug.cgi?id=547566

The bug report contains a recipe for reproducing the bug.

Below is a cut and paste of the original report:

Description of problem:

Using emacs hexl-mode to simply overwrite/change a few bytes in a file caused
file corruption in the saved file.  A whole line of bytes (16 bytes) went
missing from the original file.  The saved file is now 16 bytes shorter than
the original.

Version-Release number of selected component (if applicable):
23.1-7.fc11.x86_64

How reproducible:
always

Steps to Reproduce:
1. emacs emacs-hexl-before.pcap
2. M-x hexl-mode
3. Move cursor to byte 0x20 (1st one in 3rd line)
4. Edit byte 0x20 to be 0x64: C-M-x.  In the Hex number: entry, type 64
5. Edit byte 0x21 to be 0x01: C-M-x.  In the Hex number: entry, type 01
6. Move cursor to byte 0x24
7. Edit byte 0x24 to be 0x64: C-M-x.  In the Hex number: entry, type 64
8. Edit byte 0x25 to be 0x01: C-M-x.  In the Hex number: entry, type 01
9. Move cursor to byte 0x38
10. Edit byte 0x38 to be 0x01: C-M-x.  In the Hex number: entry, type 01
11. Edit byte 0x39 to be 0x56: C-M-x.  In the Hex number: entry, type 56
12. Move cursor to byte 0x40
13. Edit byte 0x40 to be 0x79: C-M-x.  In the Hex number: entry, type 79
14. Edit byte 0x41 to be 0x98: C-M-x.  In the Hex number: entry, type 98
15. Move cursor to byte 0x4e
16. Edit byte 0x4e to be 0x01: C-M-x.  In the Hex number: entry, type 01
17. Edit byte 0x4f to be 0x42: C-M-x.  In the Hex number: entry, type 42
18. Edit byte 0x50 to be 0xfb: C-M-x.  In the Hex number: entry, type fb
19. Edit byte 0x51 to be 0x24: C-M-x.  In the Hex number: entry, type 24
20. Save file: C-x C-w emacs-hexl-after.pcap
21. hexdump -C -v emacs-hexl-before.pcap > emacs-hexl-before.hex
22. hexdump -C -v emacs-hexl-after.pcap > emacs-hexl-after.hex
23. diff -ub emacs-hexl-before.hex emacs-hexl-after.hex

Actual results:

Comparing the original file to the edited file, the expected changes have been
made however additionally bytes 0x60-0x6f went missing and the original bytes
starting from 0x70 have been shifted down to position 0x60.  I.e. 16 bytes from
0x60-0x6f have been deleted and the remainder of the file shifted down.  The
saved file is also exactly 16 bytes shorter than the original.  Thus the file
has become corrupted.

Expected results:

No truncation/corruption of the file when editing bytes in-place.





Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5313; Package emacs. (Thu, 14 Jan 2010 00:51:04 GMT) Full text and rfc822 format available.

Message #8 received at 5313 <at> debbugs.gnu.org (full text, mbox):

From: Juanma Barranquero <lekktu <at> gmail.com>
To: Jonathan Underwood <jonathan.underwood <at> gmail.com>
Cc: 5313 <at> debbugs.gnu.org
Subject: Re: bug#5313: editing files in hexl-mode corrupts file
Date: Thu, 14 Jan 2010 01:50:34 +0100
On Mon, Jan 4, 2010 at 14:35, Jonathan Underwood
<jonathan.underwood <at> gmail.com> wrote:

> A bug report was filed downstream about hexl-mode corrupting a file
> during editing:
>
> https://bugzilla.redhat.com/show_bug.cgi?id=547566

Could you please try the following patch?

    Juanma


=== modified file 'lisp/hexl.el'
--- lisp/hexl.el	2010-01-13 08:35:10 +0000
+++ lisp/hexl.el	2010-01-14 00:38:04 +0000
@@ -779,7 +779,7 @@

 (defun hexl-printable-character (ch)
   "Return a displayable string for character CH."
-  (format "%c" (if hexl-iso
+  (format "%c" (if (not (equal hexl-iso ""))
 		   (if (or (< ch 32) (and (>= ch 127) (< ch 160)))
 		       46
 		     ch)




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5313; Package emacs. (Thu, 14 Jan 2010 13:39:01 GMT) Full text and rfc822 format available.

Message #11 received at 5313 <at> debbugs.gnu.org (full text, mbox):

From: Jonathan Underwood <jonathan.underwood <at> gmail.com>
To: Juanma Barranquero <lekktu <at> gmail.com>
Cc: 5313 <at> debbugs.gnu.org
Subject: Re: bug#5313: editing files in hexl-mode corrupts file
Date: Thu, 14 Jan 2010 13:36:48 +0000
2010/1/14 Juanma Barranquero <lekktu <at> gmail.com>:
> Could you please try the following patch?
>
> === modified file 'lisp/hexl.el'
> --- lisp/hexl.el        2010-01-13 08:35:10 +0000
> +++ lisp/hexl.el        2010-01-14 00:38:04 +0000
> @@ -779,7 +779,7 @@
>
>  (defun hexl-printable-character (ch)
>   "Return a displayable string for character CH."
> -  (format "%c" (if hexl-iso
> +  (format "%c" (if (not (equal hexl-iso ""))
>                   (if (or (< ch 32) (and (>= ch 127) (< ch 160)))
>                       46
>                     ch)
>

Thanks. I have pushed builds for Fedora 11 and 12 incorporating that patch.




Reply sent to Juanma Barranquero <lekktu <at> gmail.com>:
You have taken responsibility. (Thu, 14 Jan 2010 14:40:02 GMT) Full text and rfc822 format available.

Notification sent to Jonathan Underwood <jonathan.underwood <at> gmail.com>:
bug acknowledged by developer. (Thu, 14 Jan 2010 14:40:02 GMT) Full text and rfc822 format available.

Message #16 received at 5313-done <at> debbugs.gnu.org (full text, mbox):

From: Juanma Barranquero <lekktu <at> gmail.com>
To: Jonathan Underwood <jonathan.underwood <at> gmail.com>
Cc: 5313-done <at> debbugs.gnu.org
Subject: Re: bug#5313: editing files in hexl-mode corrupts file
Date: Thu, 14 Jan 2010 15:39:23 +0100
On Thu, Jan 14, 2010 at 14:36, Jonathan Underwood
<jonathan.underwood <at> gmail.com> wrote:

> Thanks. I have pushed builds for Fedora 11 and 12 incorporating that patch.

I've installed in the trunk a slight variation of this patch (same
change, but the if/else parts inverted to avoid "(if (not (equal".

    Juanma




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5313; Package emacs. (Thu, 14 Jan 2010 15:02:01 GMT) Full text and rfc822 format available.

Message #19 received at 5313 <at> debbugs.gnu.org (full text, mbox):

From: Jonathan Underwood <jonathan.underwood <at> gmail.com>
To: 5313 <at> debbugs.gnu.org
Subject: Re: bug#5313 closed by Juanma Barranquero <lekktu <at> gmail.com> (Re: 
	bug#5313: editing files in hexl-mode corrupts file)
Date: Thu, 14 Jan 2010 14:51:40 +0000
2010/1/14 Emacs bug Tracking System <bug-gnu-emacs <at> gnu.org>:
> I've installed in the trunk a slight variation of this patch (same
> change, but the if/else parts inverted to avoid "(if (not (equal".
>
>    Juanma

Might be a good idea to push it to the 23.2 branch too, if possible.




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5313; Package emacs. (Thu, 14 Jan 2010 16:01:02 GMT) Full text and rfc822 format available.

Message #22 received at 5313 <at> debbugs.gnu.org (full text, mbox):

From: Chong Yidong <cyd <at> stupidchicken.com>
To: Jonathan Underwood <jonathan.underwood <at> gmail.com>
Cc: 5313 <at> debbugs.gnu.org
Subject: Re: bug#5313: closed by Juanma Barranquero <lekktu <at> gmail.com> (Re:
	bug#5313: editing files in hexl-mode corrupts file)
Date: Thu, 14 Jan 2010 11:00:09 -0500
Jonathan Underwood <jonathan.underwood <at> gmail.com> writes:

> Might be a good idea to push it to the 23.2 branch too, if possible.

Trunk will become 23.2.




bug archived. Request was from Debbugs Internal Request <bug-gnu-emacs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 12 Feb 2010 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 15 years and 131 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.