]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Fix sub-collection testing (Issue #4096)
authorMichael R Sweet <michaelrsweet@gmail.com>
Thu, 14 Dec 2017 22:14:00 +0000 (17:14 -0500)
committerMichael R Sweet <michaelrsweet@gmail.com>
Thu, 14 Dec 2017 22:14:00 +0000 (17:14 -0500)
cups/dest-options.c

index 2eec872ccfbea850d6fdfe7cfb4b9277b51fe73d..18abebf06afe4778f7c7b0e0126ec28bcaffab25 100644 (file)
@@ -1354,8 +1354,9 @@ static int                                /* O - 1 on a match, 0 on a non-match */
 cups_collection_contains(ipp_t *test,  /* I - Collection to test */
                          ipp_t *match) /* I - Matching values */
 {
-  int                  i,              /* Looping var */
-                       count;          /* Number of test values */
+  int                  i, j,           /* Looping vars */
+                       mcount,         /* Number of match values */
+                       tcount;         /* Number of test values */
   ipp_attribute_t      *tattr,         /* Testing attribute */
                        *mattr;         /* Matching attribute */
   const char           *tval;          /* Testing string value */
@@ -1366,7 +1367,7 @@ cups_collection_contains(ipp_t *test,     /* I - Collection to test */
     if ((tattr = ippFindAttribute(test, ippGetName(mattr), IPP_TAG_ZERO)) == NULL)
       return (0);
 
-    count = ippGetCount(tattr);
+    tcount = ippGetCount(tattr);
 
     switch (ippGetValueTag(mattr))
     {
@@ -1375,7 +1376,7 @@ cups_collection_contains(ipp_t *test,     /* I - Collection to test */
           if (ippGetValueTag(tattr) != ippGetValueTag(mattr))
             return (0);
 
-          for (i = 0; i < count; i ++)
+          for (i = 0; i < tcount; i ++)
           {
             if (!ippContainsInteger(mattr, ippGetInteger(tattr, i)))
               return (0);
@@ -1386,7 +1387,7 @@ cups_collection_contains(ipp_t *test,     /* I - Collection to test */
           if (ippGetValueTag(tattr) != IPP_TAG_INTEGER)
             return (0);
 
-          for (i = 0; i < count; i ++)
+          for (i = 0; i < tcount; i ++)
           {
             if (!ippContainsInteger(mattr, ippGetInteger(tattr, i)))
               return (0);
@@ -1408,13 +1409,25 @@ cups_collection_contains(ipp_t *test,   /* I - Collection to test */
       case IPP_TAG_CHARSET :
       case IPP_TAG_LANGUAGE :
       case IPP_TAG_MIMETYPE :
-          for (i = 0; i < count; i ++)
+          for (i = 0; i < tcount; i ++)
           {
             if ((tval = ippGetString(tattr, i, NULL)) == NULL || !ippContainsString(mattr, tval))
               return (0);
           }
           break;
 
+      case IPP_TAG_BEGIN_COLLECTION :
+          for (i = 0; i < tcount; i ++)
+          {
+            ipp_t *tcol = ippGetCollection(tattr, i);
+                                       /* Testing collection */
+
+            for (j = 0, mcount = ippGetCount(mattr); j < mcount; j ++)
+              if (!cups_collection_contains(tcol, ippGetCollection(mattr, j)))
+                return (0);
+          }
+          break;
+
       default :
           return (0);
     }