You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bugs@httpd.apache.org by bu...@apache.org on 2002/09/13 16:54:59 UTC
DO NOT REPLY [Bug 12615] New: -
Incorrect comparison in misc/unix/rand.c
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=12615>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=12615
Incorrect comparison in misc/unix/rand.c
Summary: Incorrect comparison in misc/unix/rand.c
Product: APR
Version: HEAD
Platform: Other
OS/Version: Other
Status: NEW
Severity: Normal
Priority: Other
Component: APR
AssignedTo: bugs@httpd.apache.org
ReportedBy: tenthumbs@cybernex.net
I found this while building apache 2.0.40 but it's in the current APR as well.
In apr/misc/unix/rand.c, Linux gcc 3.1.1 says
rand.c:95: warning: comparison of unsigned expression < 0 is always false
and the code is
89 apr_size_t got, tot;
90
91 if ((rnd = open(STR(DEV_RANDOM), O_RDONLY)) == -1)
92 return errno;
93
94 for (tot=0; tot<length; tot += got)
95 if ((got = read(rnd, buf+tot, length-tot)) < 0)
96 return errno;
While read may return a signed value, got is unsigned so the error return
becomes unreachable and gcc optimizes it away. That's not what's intended.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org