]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - backend/ipp.c
Fix memory leaks found by Coverity (Issue #5375)
[thirdparty/cups.git] / backend / ipp.c
index 29ef3d6e0624956cb467bbee26b321757701d475..f62304ac6fff8e035a988fe7f3111919918817e3 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * IPP backend 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
@@ -1140,7 +1140,14 @@ main(int  argc,                          /* I - Number of command-line args */
        copies_sup = NULL; /* No */
     }
 
-    cups_version = ippFindAttribute(supported, "cups-version", IPP_TAG_TEXT);
+    if ((cups_version = ippFindAttribute(supported, "cups-version", IPP_TAG_TEXT)) != NULL)
+    {
+      const char *version = ippGetString(cups_version, 0, NULL);
+
+      fprintf(stderr, "DEBUG: cups-version = \"%s\"\n", version);
+      if (!strcmp(version, "cups-version"))
+        cups_version = NULL;           /* Bogus cups-version value returned by buggy printers! */
+    }
 
     encryption_sup = ippFindAttribute(supported, "job-password-encryption-supported", IPP_TAG_KEYWORD);
 
@@ -2798,7 +2805,9 @@ new_request(
         _httpDecodeURI(phone, keyword, sizeof(phone));
         for (ptr = phone; *ptr;)
        {
-         if (!strchr(allowed, *ptr))
+         if (*ptr == ',')
+           *ptr = 'p';
+         else if (!strchr(allowed, *ptr))
            _cups_strcpy(ptr, ptr + 1);
          else
            ptr ++;
@@ -3584,6 +3593,8 @@ update_reasons(ipp_attribute_t *attr,     /* I - printer-state-reasons or NULL */
     }
   }
 
+  cupsArrayDelete(new_reasons);
+
   _cupsMutexUnlock(&report_mutex);
 
  /*