Skip to content

Commit 824365e

Browse files
zdohnaltillkamppeter
authored andcommitted
ppd-ipp.c: Use correct number of items to prevent buffer overflow
The array members are strings, so we can get correct number of times by dividing the array size by char* size. debug.c: Protect against possible format string attack ppd-collection.cxx: Use intmax_t for printing time_t var
1 parent 96357c9 commit 824365e

3 files changed

Lines changed: 5 additions & 4 deletions

File tree

ppd/debug.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ _ppd_debug_set(const char *logfile, // I - Log file or NULL
257257
{
258258
char buffer[1024]; // Filename buffer
259259

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

262262
if (buffer[0] == '+')
263263
_ppd_debug_fd = open(buffer + 1, O_WRONLY | O_APPEND | O_CREAT, 0644);

ppd/ppd-collection.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -848,9 +848,9 @@ ppdCollectionDumpCache(const char *filename, // I - Filename
848848
for (ppd = (ppd_info_t *)cupsArrayGetFirst(ppdlist.PPDsByName);
849849
ppd;
850850
ppd = (ppd_info_t *)cupsArrayGetNext(ppdlist.PPDsByName))
851-
printf("%d,%ld,%d,%d,\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\","
851+
printf("%jd,%ld,%d,%d,\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\","
852852
"\"%s\",\"%s\"\n",
853-
(int)ppd->record.mtime, (long)ppd->record.size,
853+
(intmax_t)ppd->record.mtime, (long)ppd->record.size,
854854
ppd->record.model_number, ppd->record.type, ppd->record.filename,
855855
ppd->record.name, ppd->record.languages[0], ppd->record.products[0],
856856
ppd->record.psversions[0], ppd->record.make,

ppd/ppd-ipp.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1321,7 +1321,8 @@ ppdLoadAttributes(
13211321
(ppd_option = ppdFindOption(ppd, "print-rendering-intent")) != NULL) &&
13221322
ppd_option->num_choices > 0)
13231323
{
1324-
for (i = 0; i < ppd_option->num_choices && i < sizeof(items); i ++)
1324+
num_items = sizeof(items)/sizeof(char*);
1325+
for (i = 0; i < ppd_option->num_choices && i < num_items; i ++)
13251326
items[i] = ppd_option->choices[i].choice;
13261327
ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
13271328
"print-rendering-intent-supported", i, NULL, items);

0 commit comments

Comments
 (0)