Skip to content

Commit

Permalink
Validate URIs and attribute names before putting them in the generate…
Browse files Browse the repository at this point in the history
…d PPD.
  • Loading branch information
michaelrsweet committed Sep 7, 2024
1 parent 563d271 commit 96b3bdf
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions cups/ppd-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -3340,10 +3340,10 @@ _ppdCreateFromIPP(char *buffer, /* I - Filename buffer */

base_lang = cupsLangGet("en");

if ((attr = ippFindAttribute(supported, "printer-more-info", IPP_TAG_URI)) != NULL)
if ((attr = ippFindAttribute(supported, "printer-more-info", IPP_TAG_URI)) != NULL && ippValidateAttribute(attr))
cupsFilePrintf(fp, "*APSupplies: \"%s\"\n", ippGetString(attr, 0, NULL));

if ((attr = ippFindAttribute(supported, "printer-charge-info-uri", IPP_TAG_URI)) != NULL)
if ((attr = ippFindAttribute(supported, "printer-charge-info-uri", IPP_TAG_URI)) != NULL && ippValidateAttribute(attr))
cupsFilePrintf(fp, "*cupsChargeInfoURI: \"%s\"\n", ippGetString(attr, 0, NULL));

/*
Expand All @@ -3356,10 +3356,10 @@ _ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
if (ippGetBoolean(ippFindAttribute(supported, "job-accounting-user-id-supported", IPP_TAG_BOOLEAN), 0))
cupsFilePuts(fp, "*cupsJobAccountingUserId: True\n");

if ((attr = ippFindAttribute(supported, "printer-privacy-policy-uri", IPP_TAG_URI)) != NULL)
if ((attr = ippFindAttribute(supported, "printer-privacy-policy-uri", IPP_TAG_URI)) != NULL && ippValidateAttribute(attr))
cupsFilePrintf(fp, "*cupsPrivacyURI: \"%s\"\n", ippGetString(attr, 0, NULL));

if ((attr = ippFindAttribute(supported, "printer-mandatory-job-attributes", IPP_TAG_KEYWORD)) != NULL)
if ((attr = ippFindAttribute(supported, "printer-mandatory-job-attributes", IPP_TAG_KEYWORD)) != NULL && ippValidateAttribute(attr))
{
for (i = 0, count = ippGetCount(attr), prefix = "*cupsMandatory: \""; i < count; i ++)
{
Expand All @@ -3376,7 +3376,7 @@ _ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
cupsFilePuts(fp, "\"\n");
}

if ((attr = ippFindAttribute(supported, "printer-requested-job-attributes", IPP_TAG_KEYWORD)) != NULL)
if ((attr = ippFindAttribute(supported, "printer-requested-job-attributes", IPP_TAG_KEYWORD)) != NULL && ippValidateAttribute(attr))
{
for (i = 0, count = ippGetCount(attr), prefix = "*cupsRequested: \""; i < count; i ++)
{
Expand Down

1 comment on commit 96b3bdf

@s0ssh
Copy link

@s0ssh s0ssh commented on 96b3bdf Sep 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uh oh

Please sign in to comment.