mirror of
https://github.com/sudo-project/sudo.git
synced 2025-09-05 00:35:14 +00:00
Properly check against errors against fwrite
fwrite is not the same as write; you have to explicitly compare against the length to detect errors, and sometimes number of items is mistaken for length.
This commit is contained in:
@@ -68,8 +68,8 @@ sudo_printf_int(int msg_type, const char * restrict fmt, ...)
|
||||
len = vasprintf(&buf, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
if (len != -1) {
|
||||
if (fwrite(buf, 1, (size_t)len, ttyfp ? ttyfp : fp) == 0)
|
||||
if (len >= 0) {
|
||||
if (fwrite(buf, 1, (size_t)len, ttyfp ? ttyfp : fp) != (size_t)len)
|
||||
len = -1;
|
||||
if (buf != sbuf)
|
||||
free(buf);
|
||||
|
Reference in New Issue
Block a user