From owner-freebsd-current Fri Sep 6 9: 8:28 2002 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8D7CF37B401; Fri, 6 Sep 2002 09:08:12 -0700 (PDT) Received: from rwcrmhc52.attbi.com (rwcrmhc52.attbi.com [216.148.227.88]) by mx1.FreeBSD.org (Postfix) with ESMTP id ADC3743E42; Fri, 6 Sep 2002 09:08:11 -0700 (PDT) (envelope-from bmah@employees.org) Received: from bmah.dyndns.org ([12.233.149.189]) by rwcrmhc52.attbi.com (InterMail vM.4.01.03.27 201-229-121-127-20010626) with ESMTP id <20020906160811.BIHW22980.rwcrmhc52.attbi.com@bmah.dyndns.org>; Fri, 6 Sep 2002 16:08:11 +0000 Received: from intruder.bmah.org (localhost [IPv6:::1]) by bmah.dyndns.org (8.12.6/8.12.6) with ESMTP id g86G8AsU001415; Fri, 6 Sep 2002 09:08:10 -0700 (PDT) (envelope-from bmah@intruder.bmah.org) Received: (from bmah@localhost) by intruder.bmah.org (8.12.6/8.12.6/Submit) id g86G8AOF001414; Fri, 6 Sep 2002 09:08:10 -0700 (PDT) Message-Id: <200209061608.g86G8AOF001414@intruder.bmah.org> X-Mailer: exmh version 2.5+ 20020729 with nmh-1.0.4 To: freebsd-current@freebsd.org Cc: bmah@freebsd.org Subject: libmd bug on -CURRENT From: bmah@freebsd.org (Bruce A. Mah) Reply-To: bmah@freebsd.org X-Face: g~c`.{#4q0"(V*b#g[i~rXgm*w;:nMfz%_RZLma)UgGN&=j`5vXoU^@n5v4:OO)c["!w)nD/!!~e4Sj7LiT'6*wZ83454H""lb{CC%T37O!!'S$S&D}sem7I[A 2V%N&+ X-Image-Url: http://www.employees.org/~bmah/Images/bmah-cisco-small.gif X-Url: http://www.employees.org/~bmah/ Mime-Version: 1.0 Content-Type: multipart/signed; boundary="==_Exmh_-1731682532P"; micalg=pgp-sha1; protocol="application/pgp-signature" Content-Transfer-Encoding: 7bit Date: Fri, 06 Sep 2002 09:08:10 -0700 Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --==_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