Date: Fri, 06 Sep 2002 09:08:10 -0700 From: bmah@freebsd.org (Bruce A. Mah) To: freebsd-current@freebsd.org Cc: bmah@freebsd.org Subject: libmd bug on -CURRENT Message-ID: <200209061608.g86G8AOF001414@intruder.bmah.org>
next in thread | raw e-mail | index | archive | help
--==_Exmh_-1731682532P Content-Type: text/plain; charset=us-ascii I think I've found a bug in libmd on -CURRENT, in which attempting to compute the MD5 checksum (using MD5File(3)) of a zero-length file generates an error. A trivial way to trigger this bug (which isn't present in 4-STABLE) is: ref4:bmah% uname -a FreeBSD ref4.freebsd.org 4.7-PRERELEASE FreeBSD 4.7-PRERELEASE #8: Mon Sep 2 03:20:42 PDT 2002 peter@ref4.freebsd.org:/usr/src/sys/compile/REF4 i386 ref4:bmah% ls -ls foo 0 -rw-r--r-- 1 bmah bmah 0 Sep 6 08:54 foo ref4:bmah% md5 foo MD5 (foo) = d41d8cd98f00b204e9800998ecf8427e ref5:bmah% uname -a FreeBSD ref5.freebsd.org 5.0-CURRENT FreeBSD 5.0-CURRENT #11: Mon Sep 2 03:30:53 PDT 2002 peter@ref5.freebsd.org:/usr/src/sys/i386/compile/REF5 i386 ref5:bmah% ls -ls foo 0 -rw-r--r-- 1 bmah bmah 0 Sep 6 08:54 foo ref5:bmah% md5 foo md5: foo: Undefined error: 0 This bug seems to have been introduced in rev. 1.14 of src/lib/libmd/ mdXhl.c; the patch below (which makes sure a variable gets initialized before first use, even in the case of a 0-length file) seems to fix it. Comments? Bruce. PS. I found this because at some point during a release build, mtree(8) tries to compute the MD5 checksum of a zero-length file, namely /etc/dumpdates. Index: mdXhl.c =================================================================== RCS file: /usr/local/cvsroot/src/lib/libmd/mdXhl.c,v retrieving revision 1.16 diff -u -r1.16 mdXhl.c --- mdXhl.c 25 Mar 2002 13:50:40 -0000 1.16 +++ mdXhl.c 6 Sep 2002 16:02:52 -0000 @@ -66,6 +66,7 @@ len = stbuf.st_size - ofs; if (lseek(f, ofs, SEEK_SET) < 0) return 0; n = len; + i = 0; while (n > 0) { if (n > sizeof(buffer)) i = read(f, buffer, sizeof(buffer)); --==_Exmh_-1731682532P Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (FreeBSD) Comment: Exmh version 2.5+ 20020506 iD8DBQE9eNLq2MoxcVugUsMRAmFEAKDczdvrMCDb+1+KoIIz4v2KQlXEwACfVdOD Ro363L7jVVGoJU7byeABlRw= =pu1n -----END PGP SIGNATURE----- --==_Exmh_-1731682532P-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200209061608.g86G8AOF001414>