Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues reported by OpenScanHub #54

Merged
merged 7 commits into from
Feb 5, 2025
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
2 changes: 1 addition & 1 deletion ppd/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ _ppd_debug_set(const char *logfile, // I - Log file or NULL
{
char buffer[1024]; // Filename buffer

snprintf(buffer, sizeof(buffer), logfile, getpid());
snprintf(buffer, sizeof(buffer), "%s-%d", logfile, (int)getpid());

if (buffer[0] == '+')
_ppd_debug_fd = open(buffer + 1, O_WRONLY | O_APPEND | O_CREAT, 0644);
Expand Down
5 changes: 5 additions & 0 deletions ppd/imagetops-pstops.c
Original file line number Diff line number Diff line change
Expand Up @@ -1178,6 +1178,9 @@ ppdFilterImageToPS(int inputfd, // I - File descriptor input
if (log) log(ld, CF_LOGLEVEL_ERROR,
"ppdFilterImageToPS: The print file could not be opened - %s",
strerror(errno));
cfImageClose(img);
fclose(doc.outputfp);
close(outputfd);
return (1);
}

Expand Down Expand Up @@ -1589,6 +1592,8 @@ ppdFilterImageToPS(int inputfd, // I - File descriptor input
log(ld, CF_LOGLEVEL_ERROR,
"ppdFilterImageToPS: Could not allocate memory.");
cfImageClose(img);
fclose(doc.outputfp);
close(outputfd);
return (2);
}

Expand Down
2 changes: 1 addition & 1 deletion ppd/ppd-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ ppdCacheCreateWithFile(

cupsArrayAdd(pc->prefilters, value);
}
else if (!_ppd_strcasecmp(line, "Product"))
else if (!pc->product && !_ppd_strcasecmp(line, "Product"))
{
pc->product = strdup(value);
}
Expand Down
20 changes: 12 additions & 8 deletions ppd/ppd-collection.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ typedef union // **** TAR record format ****
chksum[8], // Octal checksum value
linkflag, // File type
linkname[100], // Source path for link
magic[6], // Magic string
magic[8], // Magic string
version[2], // Format version
uname[32], // User name
gname[32], // Group name
Expand Down Expand Up @@ -232,6 +232,7 @@ ppdCollectionListPPDs(
ppdlist.PPDsByMakeModel = cupsArrayNew((cups_array_cb_t)compare_ppds,
NULL, NULL, 0, NULL, NULL);
ppdlist.ChangedPPD = 0;
ppdlist.Inodes = NULL;


//
Expand Down Expand Up @@ -847,9 +848,9 @@ ppdCollectionDumpCache(const char *filename, // I - Filename
for (ppd = (ppd_info_t *)cupsArrayGetFirst(ppdlist.PPDsByName);
ppd;
ppd = (ppd_info_t *)cupsArrayGetNext(ppdlist.PPDsByName))
printf("%d,%ld,%d,%d,\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\","
printf("%jd,%ld,%d,%d,\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\","
"\"%s\",\"%s\"\n",
(int)ppd->record.mtime, (long)ppd->record.size,
(intmax_t)ppd->record.mtime, (long)ppd->record.size,
ppd->record.model_number, ppd->record.type, ppd->record.filename,
ppd->record.name, ppd->record.languages[0], ppd->record.products[0],
ppd->record.psversions[0], ppd->record.make,
Expand Down Expand Up @@ -1273,11 +1274,14 @@ free_ppdlist(ppd_list_t *ppdlist) // I - PPD list to free
ppd_info_t *ppd; // Pointer to PPD info


for (dinfoptr = (struct stat *)cupsArrayGetFirst(ppdlist->Inodes);
dinfoptr;
dinfoptr = (struct stat *)cupsArrayGetNext(ppdlist->Inodes))
free(dinfoptr);
cupsArrayDelete(ppdlist->Inodes);
if (ppdlist->Inodes)
{
for (dinfoptr = (struct stat *)cupsArrayGetFirst(ppdlist->Inodes);
dinfoptr;
dinfoptr = (struct stat *)cupsArrayGetNext(ppdlist->Inodes))
free(dinfoptr);
cupsArrayDelete(ppdlist->Inodes);
}

for (ppd = (ppd_info_t *)cupsArrayGetFirst(ppdlist->PPDsByName);
ppd;
Expand Down
3 changes: 2 additions & 1 deletion ppd/ppd-ipp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1321,7 +1321,8 @@ ppdLoadAttributes(
(ppd_option = ppdFindOption(ppd, "print-rendering-intent")) != NULL) &&
ppd_option->num_choices > 0)
{
for (i = 0; i < ppd_option->num_choices && i < sizeof(items); i ++)
num_items = sizeof(items)/sizeof(char*);
for (i = 0; i < ppd_option->num_choices && i < num_items; i ++)
items[i] = ppd_option->choices[i].choice;
ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
"print-rendering-intent-supported", i, NULL, items);
Expand Down
2 changes: 1 addition & 1 deletion ppd/ppd-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -3059,7 +3059,7 @@ check_filters(ppd_file_t *ppd, // I - PPD file
type[256], // Type for filter
dstsuper[16], // Destination super-type for filter
dsttype[256], // Destination type for filter
program[128], // Program/filter name
program[1024], // Program/filter name
pathprog[1024]; // Complete path to program/filter
int cost; // Cost of filter
const char *prefix; // WARN/FAIL prefix
Expand Down
5 changes: 5 additions & 0 deletions ppd/rastertops.c
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,12 @@ ppdFilterRasterToPS(int inputfd, // I - File descriptor input stream
{
if (log) log(ld, CF_LOGLEVEL_DEBUG,
"ppdFilterRasterToPS: Input is empty, outputting empty file.");

cupsRasterClose(ras);
cupsFileClose(inputfp);
fclose(outputfp);
close(outputfd);

return (0);
}

Expand Down