Skip to content

Commit edf1393

Browse files
authored
Merge commit from fork
Prevent PPD generation based on invalid IPP response
2 parents 0d90320 + d681747 commit edf1393

2 files changed

Lines changed: 176 additions & 98 deletions

File tree

ppd/ppd-cache.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//
22
// PPD cache implementation for libppd.
33
//
4+
// Copyright © 2024 by OpenPrinting
45
// Copyright © 2010-2019 by Apple Inc.
56
//
67
// Licensed under Apache License v2.0. See the file "LICENSE" for more
@@ -3434,7 +3435,7 @@ ppdCacheGetBin(
34343435

34353436
//
34363437
// Range check input...
3437-
3438+
34383439

34393440
if (!pc || !output_bin)
34403441
return (NULL);
@@ -3935,7 +3936,7 @@ ppdCacheGetPageSize(
39353936
{
39363937
//
39373938
// Check not only the base size (like "A4") but also variants (like
3938-
// "A4.Borderless"). We check only the margins and orientation but do
3939+
// "A4.Borderless"). We check only the margins and orientation but do
39393940
// not re-check the size.
39403941
//
39413942

@@ -4776,7 +4777,7 @@ ppdPwgPpdizeName(const char *ipp, // I - IPP keyword
47764777
*end; // End of name buffer
47774778

47784779

4779-
if (!ipp)
4780+
if (!ipp || !_ppd_isalnum(*ipp))
47804781
{
47814782
*name = '\0';
47824783
return;
@@ -4786,13 +4787,19 @@ ppdPwgPpdizeName(const char *ipp, // I - IPP keyword
47864787

47874788
for (ptr = name + 1, end = name + namesize - 1; *ipp && ptr < end;)
47884789
{
4789-
if (*ipp == '-' && _ppd_isalnum(ipp[1]))
4790+
if (*ipp == '-' && isalnum(ipp[1]))
47904791
{
47914792
ipp ++;
47924793
*ptr++ = (char)toupper(*ipp++ & 255);
47934794
}
4794-
else
4795+
else if (*ipp == '_' || *ipp == '.' || *ipp == '-' || isalnum(*ipp))
4796+
{
47954797
*ptr++ = *ipp++;
4798+
}
4799+
else
4800+
{
4801+
ipp ++;
4802+
}
47964803
}
47974804

47984805
*ptr = '\0';

0 commit comments

Comments
 (0)