Skip to content

Commit

Permalink
ppd-emit.c: Fix SEGV in 'ppdEmitString()'
Browse files Browse the repository at this point in the history
When using testppd.c as a harness, a fuzzer found a way to call
ppdPageSize() with NULL return value. This caused a segmentation fault
because the size structure, which is used by values[pos],
was assigned a NULL value. To avoid this, we need to add a
NULL value check for the size structure, free allocated memory,
and return NULL.

Fixes OpenPrinting#849
  • Loading branch information
Drawishe committed Dec 27, 2023
1 parent 79c602c commit 9e807ac
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cups/ppd-emit.c
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,12 @@ ppdEmitString(ppd_file_t *ppd, /* I - PPD file record */
cupsCopyString(bufptr, "%%BeginFeature: *CustomPageSize True\n", (size_t)(bufend - bufptr + 1));
bufptr += 37;

size = ppdPageSize(ppd, "Custom");
if ((size = ppdPageSize(ppd, "Custom")) == NULL)
{
free(buffer);
free(choices);
return(NULL);
}

memset(values, 0, sizeof(values));

Expand Down

0 comments on commit 9e807ac

Please sign in to comment.