Skip to content

Commit c2db921

Browse files
sahlbergtridge
authored andcommitted
options.c: Fix segv if poptGetContext returns NULL
If poptGetContext returns NULL, perhaps due to OOM, a NULL pointer is passed into poptReadDefaultConfig() which in turns SEGVs when trying to dereference it. This was found using https://github.com/sahlberg/malloc-fail-tester.git $ ./test_malloc_failure.sh rsync -Pav crash crosh Signed-off-by: Ronnie Sahlberg <[email protected]>
1 parent 77be09a commit c2db921

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

options.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,6 +1372,10 @@ int parse_arguments(int *argc_p, const char ***argv_p)
13721372
/* TODO: Call poptReadDefaultConfig; handle errors. */
13731373

13741374
pc = poptGetContext(RSYNC_NAME, argc, argv, long_options, 0);
1375+
if (pc == NULL) {
1376+
strlcpy(err_buf, "poptGetContext returned NULL\n", sizeof err_buf);
1377+
return 0;
1378+
}
13751379
if (!am_server) {
13761380
poptReadDefaultConfig(pc, 0);
13771381
popt_unalias(pc, "--daemon");

0 commit comments

Comments
 (0)