diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2008-01-24 11:56:30 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2008-01-24 11:56:30 +0000 |
commit | 6a25a789022c4f2c83d6f59608fa9679fdf9ddd5 (patch) | |
tree | 6f3a508c449b8578ed460484f5e01058e61ced4a | |
parent | 51c3906e5539a414a6cd57374bcd379e7e424025 (diff) |
"read(..., ..., sizeof Y) < sizeof Y" is a dangerous idiom because it
does an unsigned comparison and read() can return -1. Use '!=' instead
of '<' since read() can't return more than 'sizeof Y'. Not perfect
(that would require a separate test for -1) but a very common usage.
ok henning@
-rw-r--r-- | usr.sbin/httpd/src/main/http_protocol.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/usr.sbin/httpd/src/main/http_protocol.c b/usr.sbin/httpd/src/main/http_protocol.c index feac8582635..9e8093250ee 100644 --- a/usr.sbin/httpd/src/main/http_protocol.c +++ b/usr.sbin/httpd/src/main/http_protocol.c @@ -1,4 +1,4 @@ -/* $OpenBSD: http_protocol.c,v 1.31 2006/09/26 03:26:36 djm Exp $ */ +/* $OpenBSD: http_protocol.c,v 1.32 2008/01/24 11:56:29 krw Exp $ */ /* ==================================================================== * The Apache Software License, Version 1.1 * @@ -3096,7 +3096,7 @@ int ap_read_etag_state(pool *pconf) /* read 4 random 32-bit uints from file and update the hash context */ for (u = 0; u < 4; u++) { - if (read(fd, &rnd, sizeof(rnd)) < sizeof(rnd)) + if (read(fd, &rnd, sizeof(rnd)) != sizeof(rnd)) return (-1); ap_SHA1Update_binary(&baseCtx, (const unsigned char *)&rnd, |