Skip to content

Commit 3c78d08

Browse files
committed
read_io_buf: Treat a short read as an error
Found by the ZeroPath AI Security Engineer <https://zeropath.com>
1 parent 59afb33 commit 3c78d08

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

logsrvd/sendlog.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,9 @@ read_io_buf(struct client_closure *closure)
305305

306306
nread = (size_t)iolog_read(&closure->iolog_files[timing->event],
307307
closure->buf, timing->u.nbytes, &errstr);
308-
if (nread == (size_t)-1) {
308+
if (nread != timing->u.nbytes) {
309+
if (nread != (size_t)-1)
310+
errstr = strerror(EINVAL);
309311
sudo_warnx(U_("unable to read %s/%s: %s"), iolog_dir,
310312
iolog_fd_to_name(timing->event), errstr);
311313
debug_return_bool(false);

0 commit comments

Comments
 (0)