Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fuzz: defend against read(fd, NULL, size) and read(-1, buf, size)
Under Linux the read call seems to accept NULL as a parameter: $ cat try.c #include <unistd.h> #include <err.h> int main(void) { int i = read(0, NULL, 4); err(1, "read"); return 0; } $ make try cc try.c -o try $ ./try </dev/random try: read: Bad address Such behaviour is not specified by POSIX, so we should catch it. Since we are at it, catching read(-1, ...) is probably a good idea, since code that does that is arguably wrong.
- Loading branch information