]> 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:04 +0000 (15:14 -0400)
committerMichael R Sweet <michael.r.sweet@gmail.com>
Mon, 27 Aug 2018 19:14:04 +0000 (15:14 -0400)
CHANGES.md
cups/ppd.c
cups/ppd.h

index 12d199048c37b89c74d3a2314322370c88cf8cb3..abbbcdfc6d171a0f2bba44ccf5ac8eab3e679fb7 100644 (file)
@@ -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
index 68db74e010bd61e9304728d7d716dc5645acacba..e47a5727bd3999c304b06282dda60261b705fd11 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.
  *
  * 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...
   */
index 8b3ab24b7f29c0d41acc73edfef9ccf66ca01f51..3c46c07412307571aebdd09318708b7714002095 100644 (file)
@@ -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;