mirror of
https://github.com/sudo-project/sudo.git
synced 2025-08-28 21:07:55 +00:00
Avoid calling fread() with a NUL buffer if msg_len is 0.
Coverity CID 221399
This commit is contained in:
parent
d9f0eba1fa
commit
65a55497ec
@ -182,7 +182,8 @@ journal_seek(struct timespec *target, struct connection_closure *closure)
|
||||
break;
|
||||
}
|
||||
|
||||
/* Read actual message from journal. */
|
||||
/* Read actual message now that we know the size. */
|
||||
if (msg_len != 0) {
|
||||
if (msg_len > bufsize) {
|
||||
bufsize = sudo_pow2_roundup(msg_len);
|
||||
free(buf);
|
||||
@ -192,7 +193,6 @@ journal_seek(struct timespec *target, struct connection_closure *closure)
|
||||
}
|
||||
}
|
||||
|
||||
/* Read actual message now that we know the size. */
|
||||
nread = fread(buf, msg_len, 1, closure->journal);
|
||||
if (nread != 1) {
|
||||
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
|
||||
@ -203,6 +203,7 @@ journal_seek(struct timespec *target, struct connection_closure *closure)
|
||||
closure->errstr = _("error reading journal file");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
client_message__free_unpacked(msg, NULL);
|
||||
msg = client_message__unpack(NULL, msg_len, buf);
|
||||
|
Loading…
x
Reference in New Issue
Block a user