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 #849
  • Loading branch information
zdohnal authored Jan 4, 2024
2 parents 63f67ee + 2f8ac40 commit 0a834c3
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 0a834c3

Please sign in to comment.