joyent/libuv — Issue #317: size_t is unsigned (c99)
Author: radare
Created: 2012-02-21 12:01:31+00:00
State: open

As size_t is unsigned it is not valid to check for negative values with it. Here's one example where this can cause an error.
I have detected this bug by using the api from inside a chroot without mounted /proc. But this error should be in other places than just src/unix/linux.c

# diff -ru src/unix/linux.c.orig src/unix/linux.c
--- src/unix/linux.c.orig 2012-02-21 11:51:47.000000000 +0000
+++ src/unix/linux.c 2012-02-21 11:51:12.000000000 +0000
@@ -167,7 +167,7 @@
}

*size = readlink("/proc/self/exe", buffer, *size - 1);
- if (*size <= 0) return -1;
+ if ((int)*size <= 0) return -1;
buffer[*size] = '\0';
return 0;
}