From owner-freebsd-bugs Tue Sep 3 14:40:31 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9274737B42C for ; Tue, 3 Sep 2002 14:40:07 -0700 (PDT) Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id A239F43E6A for ; Tue, 3 Sep 2002 14:40:03 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.4/8.12.4) with ESMTP id g83Le3JU098937 for ; Tue, 3 Sep 2002 14:40:03 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.4/8.12.4/Submit) id g83Le3du098936; Tue, 3 Sep 2002 14:40:03 -0700 (PDT) Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 327B837B401 for ; Tue, 3 Sep 2002 14:37:19 -0700 (PDT) Received: from xkulesh.vol.cz (xkulesh.vol.cz [195.250.154.106]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2D9B143E7B for ; Tue, 3 Sep 2002 14:37:14 -0700 (PDT) (envelope-from dan@obluda.cz) Received: from xkulesh.vol.cz (localhost [127.0.0.1]) by xkulesh.vol.cz (8.12.5/8.12.5) with ESMTP id g83Lb8Jj000269; Tue, 3 Sep 2002 23:37:09 +0200 (CEST) (envelope-from dan@obluda.cz) Received: (from dan@localhost) by xkulesh.vol.cz (8.12.6/8.12.6/Submit) id g83KMIYd009453; Tue, 3 Sep 2002 22:22:18 +0200 (CEST) Message-Id: <200209032022.g83KMIYd009453@xkulesh.vol.cz> Date: Tue, 3 Sep 2002 22:22:18 +0200 (CEST) From: Dan Lukes Reply-To: Dan Lukes To: FreeBSD-gnats-submit@FreeBSD.org Cc: dan@obluda.cz X-Send-Pr-Version: 3.113 Subject: bin/42384: MDXFileChunk may return 0 instead of hash Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 42384 >Category: bin >Synopsis: MDXFileChunk may return 0 instead of hash >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Sep 03 14:40:03 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Dan Lukes >Release: FreeBSD 5.0-CURRENT i386 >Organization: Obludarium >Environment: src/lib/libmd/mdXhl.c,v 1.16 2002/03/25 13:50:40 >Description: During cleaning of code of libmd from warnings: lib/libmd/md2hl.c: 57: warning: 'i' might be used uninitialized in this function It is true, when MDXFileChunk called with ofs at or beyond of EOF or with zero-length file, then n == len == 0; while loop is not entered so 'i' remain uninitialised; despite of it is referenced before return. MDXFileChunk may return 0 instead of hash The patch is based on fact that 'n' must be zero on return (it's better than initialising i as it waste a few CPU cycles). >How-To-Repeat: N/A >Fix: --- lib/libmd/mdXhl.c.ORIG Mon Jul 1 22:53:29 2002 +++ lib/libmd/mdXhl.c Tue Sep 3 21:59:33 2002 @@ -78,7 +78,7 @@ e = errno; close(f); errno = e; - if (i < 0) return 0; + if (n > 0) return 0; return MDXEnd(&ctx, buf); } >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message