lpd: avoid SEGVing on immediate EOF from peer
Patch by Luís Marques <luismarques@lowrisc.org> function old new delta lpd_main 749 757 +8 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
45e3967c20
commit
ed042010dc
@ -133,6 +133,8 @@ int lpd_main(int argc UNUSED_PARAM, char *argv[])
|
|||||||
|
|
||||||
// read command
|
// read command
|
||||||
s = queue = xmalloc_read_stdin();
|
s = queue = xmalloc_read_stdin();
|
||||||
|
if (!s) // eof?
|
||||||
|
return EXIT_FAILURE;
|
||||||
// we understand only "receive job" command
|
// we understand only "receive job" command
|
||||||
if (2 != *queue) {
|
if (2 != *queue) {
|
||||||
unsupported_cmd:
|
unsupported_cmd:
|
||||||
@ -204,7 +206,7 @@ int lpd_main(int argc UNUSED_PARAM, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate input.
|
// 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])
|
if (2 != s[0] && 3 != s[0])
|
||||||
goto unsupported_cmd;
|
goto unsupported_cmd;
|
||||||
if (spooling & (1 << (s[0]-1))) {
|
if (spooling & (1 << (s[0]-1))) {
|
||||||
@ -291,7 +293,7 @@ int lpd_main(int argc UNUSED_PARAM, char *argv[])
|
|||||||
err_exit:
|
err_exit:
|
||||||
// don't keep corrupted files
|
// don't keep corrupted files
|
||||||
if (spooling) {
|
if (spooling) {
|
||||||
#define i spooling
|
int i;
|
||||||
for (i = 2; --i >= 0; )
|
for (i = 2; --i >= 0; )
|
||||||
if (filenames[i])
|
if (filenames[i])
|
||||||
unlink(filenames[i]);
|
unlink(filenames[i]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user