]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Use ssize_t which is a signed int and test if read() returns -1.
authorRoy Marples <roy@marples.name>
Sat, 11 Jul 2009 06:58:39 +0000 (06:58 +0000)
committerRoy Marples <roy@marples.name>
Sat, 11 Jul 2009 06:58:39 +0000 (06:58 +0000)
Thanks to David Wu.

signals.c

index daf0347616aa9251298e0afe691e43c9d6fcffb0..648bd311fae1a8fcdf11f5ded6ddc6024cf57840 100644 (file)
--- a/signals.c
+++ b/signals.c
@@ -71,11 +71,11 @@ signal_read(void)
 {
        int sig = -1;
        char buf[16];
-       size_t bytes;
+       ssize_t bytes;
 
        memset(buf, 0, sizeof(buf));
        bytes = read(signal_pipe[0], buf, sizeof(buf));
-       if (bytes >= sizeof(sig))
+       if (bytes >= 0 && bytes >= sizeof(sig))
                memcpy(&sig, buf, sizeof(sig));
        return sig;
 }