-
Notifications
You must be signed in to change notification settings - Fork 257
Open
Description
The project does not check for short read()s.
In C, as per man 2 read, it returns the number of Bytes read:
It is not an error if this number is smaller than the number of bytes requested; this may happen for example because fewer bytes are actually available right now
Thus you need to loop around read(), always.
Relevant code
Lines 34 to 37 in 200fef9
| /* We need one byte for the trailing 0 byte */ | |
| int n = read(fd, destination, size - 1); | |
| if (n != -1) | |
| destination[n] = '\0'; |
i3status/src/print_file_contents.c
Line 36 in 200fef9
| n = read(fd, buf, ctx->max_chars); |
This is wrong since 15 years ago:
Metadata
Metadata
Assignees
Labels
No labels