Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 3 Sep 2002 22:22:18 +0200 (CEST)
From:      Dan Lukes <dan@obluda.cz>
To:        FreeBSD-gnats-submit@FreeBSD.org
Cc:        dan@obluda.cz
Subject:   bin/42384: MDXFileChunk may return 0 instead of hash
Message-ID:  <200209032022.g83KMIYd009453@xkulesh.vol.cz>

next in thread | raw e-mail | index | archive | help

>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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200209032022.g83KMIYd009453>