[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#270241: md5sum -c gives segmentation fault on I/O errors



Package: dpkg
Version: 1.9.21

In the example below, "xx" is a file containing md5sum for file "dpkg_1.9.21.tar.gz" on a broken floppy (could be any media giving I/O error):

md5sum -v -c xx
dpkg_1.9.21.tar.gz Segmentation fault

(gdb) set args -v -c xx (gdb) run Starting program: /tmp/dpkg-1.9.21/utils/md5sum -v -c xx dpkg_1.9.21.tar.gz Program received signal SIGSEGV, Segmentation fault.
0x08049b9c in ohshite (fmt=0x804bb00 "failed in buffer_read(fd): %s") at ehandle.c:256
256       longjmp(*econtext->jbufp,1);
(gdb) bt
#0  0x08049b9c in ohshite (fmt=0x804bb00 "failed in buffer_read(fd): %s") at ehandle.c:256
#1  0x0804a366 in buffer_read (data=0xbffff724, buf=0x804e2e0, length=32768, desc=0x804e220 "mdfile") at mlib.c:230
#2  0x0804a740 in buffer_copy (read_data=0xbffff724, write_data=0xbffff718, limit=-1, desc=0x804e220 "mdfile") at mlib.c:309
#3  0x0804a60c in buffer_copy_setup (argIn={ptr = 0x8, i = 8}, typeIn=0, procIn=0x0, argOut=
      {ptr = 0xbffff81c, i = -1073743844}, typeOut=5, procOut=0x0, limit=-1, desc=0x804e220 "mdfile") at mlib.c:289
#4  0x0804a49d in buffer_copy_setup_IntPtr (n1=8, typeIn=0, procIn=0x0, n2=0xbffff81c, typeOut=5, procOut=0x0, limit=-1,
    desc=0x804b4e6 "mdfile") at mlib.c:267
#5  0x08049129 in mdfile (fd=8, digest=0xbffff81c) at md5sum.c:182
#6  0x08049360 in do_check (chkf=0x804df40) at md5sum.c:260
#7  0x08048ec3 in main (argc=1, argv=0xbffffa90) at md5sum.c:120
(gdb)


After applying the patch below:

/tmp/dpkg-1.9.21/utils/md5sum -v -c xx
dpkg_1.9.21.tar.gz md5sum: failed in buffer_read(fd): mdfile: Input/output error

--- dpkg-1.9.21/utils/md5sum.c.orig	Sun Apr 29 00:22:51 2001
+++ dpkg-1.9.21/utils/md5sum.c	Sat Sep  4 23:02:04 2004
@@ -117,6 +117,11 @@
 				break;
 			default: usage();
 		}
+		if (setjmp(ejbuf)) {
+			error_unwind(ehflag_bombout);
+			exit(1);
+		}
+		push_error_handler(&ejbuf, print_error_fatal, NULL);
 		exit(do_check(fp));
 	}
 	if (argc == 0) {



Reply to: