← Commit list

ed042010d

Denys Vlasenko
Denys Vlasenko
2019-06-07
SUCCESS Duration: 151s

Subject

lpd: avoid SEGVing on immediate EOF from peer

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

printutils/lpd.c+4 -2
@@ -133,6 +133,8 @@ int lpd_main(int argc UNUSED_PARAM, char *argv[])
// read command
s = queue = xmalloc_read_stdin();
+ if (!s) // eof?
+ return EXIT_FAILURE;
// we understand only "receive job" command
if (2 != *queue) {
unsupported_cmd:
@@ -204,7 +206,7 @@ int lpd_main(int argc UNUSED_PARAM, char *argv[])
}
// validate input.
- // we understand only "control file" or "data file" cmds
+ // we understand only "control file" or "data file" subcmds
if (2 != s[0] && 3 != s[0])
goto unsupported_cmd;
if (spooling & (1 << (s[0]-1))) {
@@ -291,7 +293,7 @@ int lpd_main(int argc UNUSED_PARAM, char *argv[])
err_exit:
// don't keep corrupted files
if (spooling) {
-#define i spooling
+ int i;
for (i = 2; --i >= 0; )
if (filenames[i])
unlink(filenames[i]);