From bac967ae5656cd6e3fc38977fb5e1222782bf7d4 Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Mon, 27 Aug 2018 15:14:04 -0400 Subject: [PATCH] Add checks for missing/bad CloseUI/JCLCloseUI keywords (Issue #5381) --- CHANGES.md | 2 ++ cups/ppd.c | 39 ++++++++++++++++++++++++++++++++++++--- cups/ppd.h | 2 ++ 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 12d199048..abbbcdfc6 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -23,6 +23,8 @@ Changes in CUPS v2.3b6 a shared CUPS printer (Issue #5361) - Fixed some memory leaks discovered by Coverity (Issue #5375) - The PPD compiler incorrectly terminated JCL options (Issue #5379) +- The cupstestppd utility did not generate errors for missing/mismatched + CloseUI/JCLCloseUI keywords (Issue #5381) - The scheduler was being backgrounded on macOS, causing applications to spin (rdar://40436080) - The scheduler did not validate that required initial request attributes were diff --git a/cups/ppd.c b/cups/ppd.c index 68db74e01..e47a5727b 100644 --- a/cups/ppd.c +++ b/cups/ppd.c @@ -1,7 +1,7 @@ /* * PPD file routines for CUPS. * - * Copyright 2007-2017 by Apple Inc. + * Copyright 2007-2018 by Apple Inc. * Copyright 1997-2007 by Easy Software Products, all rights reserved. * * Licensed under Apache License v2.0. See the file "LICENSE" for more @@ -321,7 +321,9 @@ ppdErrorString(ppd_status_t status) /* I - PPD status */ _("Bad custom parameter"), _("Missing option keyword"), _("Bad value string"), - _("Missing CloseGroup") + _("Missing CloseGroup"), + _("Bad CloseUI/JCLCloseUI"), + _("Missing CloseUI/JCLCloseUI") }; @@ -1530,8 +1532,29 @@ _ppdOpen( choice->code = _cupsStrRetain(custom_attr->value); } } - else if (!strcmp(keyword, "CloseUI") || !strcmp(keyword, "JCLCloseUI")) + else if (!strcmp(keyword, "CloseUI")) { + if ((!option || option->section == PPD_ORDER_JCL) && pg->ppd_conform == PPD_CONFORM_STRICT) + { + pg->ppd_status = PPD_BAD_CLOSE_UI; + + goto error; + } + + option = NULL; + + _cupsStrFree(string); + string = NULL; + } + else if (!strcmp(keyword, "JCLCloseUI")) + { + if ((!option || option->section != PPD_ORDER_JCL) && pg->ppd_conform == PPD_CONFORM_STRICT) + { + pg->ppd_status = PPD_BAD_CLOSE_UI; + + goto error; + } + option = NULL; _cupsStrFree(string); @@ -1994,6 +2017,16 @@ _ppdOpen( _cupsStrFree(string); } + /* + * Check for a missing CloseUI/JCLCloseUI... + */ + + if (option && pg->ppd_conform == PPD_CONFORM_STRICT) + { + pg->ppd_status = PPD_MISSING_CLOSE_UI; + goto error; + } + /* * Check for a missing CloseGroup... */ diff --git a/cups/ppd.h b/cups/ppd.h index 8b3ab24b7..3c46c0741 100644 --- a/cups/ppd.h +++ b/cups/ppd.h @@ -109,6 +109,8 @@ typedef enum ppd_status_e /**** Status Codes @deprecated@ ****/ PPD_MISSING_OPTION_KEYWORD, /* Missing option keyword */ PPD_BAD_VALUE, /* Bad value string */ PPD_MISSING_CLOSE_GROUP, /* Missing CloseGroup */ + PPD_BAD_CLOSE_UI, /* Bad CloseUI/JCLCloseUI */ + PPD_MISSING_CLOSE_UI, /* Missing CloseUI/JCLCloseUI */ PPD_MAX_STATUS /* @private@ */ } ppd_status_t; -- 2.39.2