Skip to content

Commit a642d98

Browse files
committed
edit_sudoers: Check for read() error
Found by the ZeroPath AI Security Engineer <https://zeropath.com>
1 parent 2547c50 commit a642d98

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

plugins/sudoers/visudo.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,10 @@ edit_sudoers(struct sudoersfile *sp, char *editor, int editor_argc,
521521
}
522522
lastch = buf[nread - 1];
523523
}
524+
if (nread == -1) {
525+
sudo_warn(U_("%s: read error"), sp->opath);
526+
goto done;
527+
}
524528

525529
/* Add missing newline at EOF if needed. */
526530
if (lastch != '\n') {

0 commit comments

Comments
 (0)