[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openbsd-bugs
Subject:    Possible bug in sbin/dhclient/privsep.c
From:       Antoine Brodin <antoine.brodin () laposte ! net>
Date:       2005-07-30 15:04:04
Message-ID: 20050730170404.492b9d03.antoine.brodin () laposte ! net
[Download RAW message or body]

Hi,

In buf_read() in sbin/dhclient/privsep.c, if we attempt to read 16 bytes
and we actually read 12 bytes, the short read error won't happen
because nbytes is decremented by 12.

Possible fix:
(the code could probably be simplified but this is consistent with what
buf_close() does)

--- dhclient/privsep.c.old	Sat Jul 30 16:16:48 2005
+++ dhclient/privsep.c	Sat Jul 30 16:45:34 2005
@@ -80,14 +80,11 @@ buf_read(int sock, void *buf, size_t nby
 	char *p = buf;
 
 	do {
-		n = read(sock, p, nbytes);
+		n = read(sock, p + r, nbytes - r);
 		if (n == 0)
 			error("connection closed");
-		if (n != -1) {
+		if (n != -1)
 			r += n;
-			p += n;
-			nbytes -= n;
-		}
 	} while (n == -1 && (errno == EINTR || errno == EAGAIN));
 
 	if (n == -1)

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic