]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Add checks for missing/bad CloseUI/JCLCloseUI keywords (Issue #5381)
authorMichael R Sweet <michael.r.sweet@gmail.com>
Mon, 27 Aug 2018 19:14:55 +0000 (15:14 -0400)
committerMichael R Sweet <michael.r.sweet@gmail.com>
Mon, 27 Aug 2018 19:14:55 +0000 (15:14 -0400)
CHANGES.md
cups/ppd.c
cups/ppd.h

index 817ef0610e151de204a3d292810261dc584b4267..4a7d16791955439ac64cd03de0d153cec2e44c15 100644 (file)
@@ -21,6 +21,8 @@ Changes in CUPS v2.2.9
   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
index 5bd839d1a334005f19450bbe0a623ae18a1ba4d1..276e8485e1265dd0cd8ebf4ff6be0acc6fbcd62d 100644 (file)
@@ -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.
  *
  * These coded instructions, statements, and computer programs are the
@@ -333,7 +333,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")
                };
 
 
@@ -1542,8 +1544,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);
@@ -2006,6 +2029,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...
   */
index fb33c08bfd739203af0f45151c792ac5a03f763a..6e628cb60ebbd66c1ea9a6e1ee628f8a075c24d2 100644 (file)
@@ -132,6 +132,8 @@ typedef enum ppd_status_e           /**** Status Codes @since CUPS 1.1.19/macOS 10.3@ ***
   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;