Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions projects/cups/fuzzer/fuzz_ppd_gen_1.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "ppd.h"
#include "cups.h"
#include "file-private.h"

int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
// Create a temporary file to simulate a PPD file
char filename[256];
snprintf(filename, sizeof(filename), "/tmp/fuzz_ppd_%d.ppd", getpid());

FILE *file = fopen(filename, "wb");
if (!file)
{
return 0; // Could not create file, exit
}

fwrite(data, 1, size, file);
fclose(file);

// Open the PPD file
ppd_file_t *ppd = ppdOpenFile(filename);
if (!ppd)
{
unlink(filename);
return 0; // Could not open PPD file, exit
}

// Mark default options
ppdMarkDefaults(ppd);

// Check for conflicts
int conflicts = ppdConflicts(ppd);

// Optionally mark options (using dummy options for demonstration)
cups_option_t options[1];
options[0].name = "OptionName";
options[0].value = "OptionValue";
cupsMarkOptions(ppd, 1, options);

// Close the PPD file
ppdClose(ppd);

// Clean up the temporary file
unlink(filename);

return 0;
}
Binary file added projects/cups/seeds/fuzz_ppd_gen_1_seed_corpus/1
Binary file not shown.
Binary file added projects/cups/seeds/fuzz_ppd_gen_1_seed_corpus/2
Binary file not shown.
Binary file added projects/cups/seeds/fuzz_ppd_gen_1_seed_corpus/3
Binary file not shown.