]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Coverity scan: fixed some minor issues (STR #4242)
authormike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Thu, 13 Dec 2012 21:05:15 +0000 (21:05 +0000)
committermike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Thu, 13 Dec 2012 21:05:15 +0000 (21:05 +0000)
git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@10766 7a7537e8-13f0-0310-91df-b6672ffda945

CHANGES-1.6.txt
backend/usb-libusb.c
cups/dest-options.c
cups/http-support.c
cups/ipp-support.c
cups/ipp.c
scheduler/cupsfilter.c
scheduler/job.c

index 3f64ee5455abe52a3b82d1809a4e42b77ad34969..aadd4a7e54bce6c9bfc6ad3f813d609281b6f815 100644 (file)
@@ -7,6 +7,7 @@ CHANGES IN CUPS V1.6.2
        - Security: All file, directory, user, and group settings are now stored
          in a separate cups-files.conf configuration file that cannot be set
          through the CUPS web interface or APIs (STR #4223)
+       - Coverity scan: fixed some minor issues (STR #4242)
        - The scheduler did not remove color profiles after deleting a printer
          (STR #4232)
        - The CUPS library did not always detect a timed out connection to the
index da7e0cce9d8436c50646352ad6cc117189598a99..0d472ed259dddac0702465f796506c47c6939b36 100644 (file)
@@ -672,10 +672,10 @@ print_device(const char *uri,             /* I - Device URI */
        * If it didn't exit abort the pending read and wait an additional
        * second...
        */
-  
+
       if (!g.read_thread_done)
       {
-       fputs("DEBUG: Read thread still active, aborting the pending read...\n", 
+       fputs("DEBUG: Read thread still active, aborting the pending read...\n",
              stderr);
 
        g.wait_eof = 0;
@@ -683,7 +683,7 @@ print_device(const char *uri,               /* I - Device URI */
        gettimeofday(&tv, NULL);
        cond_timeout.tv_sec  = tv.tv_sec + 1;
        cond_timeout.tv_nsec = tv.tv_usec * 1000;
-  
+
        while (!g.read_thread_done)
        {
          if (pthread_cond_timedwait(&g.read_thread_cond, &g.read_thread_mutex,
@@ -696,9 +696,6 @@ print_device(const char *uri,               /* I - Device URI */
     pthread_mutex_unlock(&g.read_thread_mutex);
   }
 
-  if (print_fd)
-    close(print_fd);
-
  /*
   * Close the connection and input file and general clean up...
   */
@@ -758,7 +755,7 @@ close_device(usb_printer_t *printer)        /* I - Printer */
       */
       if (printer->origconf > 0 && printer->origconf != number2)
       {
-       fprintf(stderr, "DEBUG: Restoring USB device configuration: %d -> %d\n", 
+       fprintf(stderr, "DEBUG: Restoring USB device configuration: %d -> %d\n",
                number2, printer->origconf);
        if ((errcode = libusb_set_configuration(printer->handle,
                                                printer->origconf)) < 0)
@@ -919,7 +916,7 @@ find_device(usb_cb_t   cb,          /* I - Callback function */
            */
 
            if (((altptr->bInterfaceClass != LIBUSB_CLASS_PRINTER ||
-                 altptr->bInterfaceSubClass != 1) && 
+                 altptr->bInterfaceSubClass != 1) &&
                 ((printer.quirks & USBLP_QUIRK_BAD_CLASS) == 0)) ||
                (altptr->bInterfaceProtocol != 1 &&     /* Unidirectional */
                 altptr->bInterfaceProtocol != 2) ||    /* Bidirectional */
@@ -997,7 +994,7 @@ find_device(usb_cb_t   cb,          /* I - Callback function */
                                            bEndpointAddress;
                }
                else
-                 fprintf(stderr, "DEBUG: Uni-directional USB communication " 
+                 fprintf(stderr, "DEBUG: Uni-directional USB communication "
                          "only!\n");
                printer.write_endp = confptr->interface[printer.iface].
                                           altsetting[printer.altset].
@@ -1376,7 +1373,7 @@ open_device(usb_printer_t *printer,       /* I - Printer */
 
   printer->origconf = current;
 
-  if ((errcode = 
+  if ((errcode =
        libusb_get_config_descriptor (printer->device, printer->conf, &confptr))
       < 0)
   {
@@ -1388,7 +1385,7 @@ open_device(usb_printer_t *printer,       /* I - Printer */
 
   if (number1 != current)
   {
-    fprintf(stderr, "DEBUG: Switching USB device configuration: %d -> %d\n", 
+    fprintf(stderr, "DEBUG: Switching USB device configuration: %d -> %d\n",
            current, number1);
     if ((errcode = libusb_set_configuration(printer->handle, number1)) < 0)
     {
index d8eff72e5b568888b7783074df34f153d25700df..8477ab30ab8849d1d7f597979629c2a7d1baf4c4 100644 (file)
@@ -485,7 +485,7 @@ cupsCopyDestConflicts(
     active = NULL;
   }
 
-  if (tries >= 0)
+  if (tries >= 100)
   {
     DEBUG_puts("1cupsCopyDestConflicts: Unable to resolve after 100 tries.");
     have_conflicts = -1;
index 2eef0bff6da001dde8a595578b9da909158bb85b..49e082706d91060e92552ec7c950df24f84ef778 100644 (file)
@@ -2064,6 +2064,8 @@ http_resolve_cb(
                        error));
 #endif /* DEBUG */
       }
+
+      httpAddrFreeList(addrlist);
     }
   }
 
@@ -2279,6 +2281,8 @@ http_resolve_cb(
                        error));
 #endif /* DEBUG */
       }
+
+      httpAddrFreeList(addrlist);
     }
   }
 
index 32804ed18e5940c17aacd1c3eb6e1d4d6009b286..842aba0c270c35cf25a11a744c6e4576054aaec5 100644 (file)
@@ -777,8 +777,8 @@ ippEnumString(const char *attrname, /* I - Attribute name */
 
   if (!strcmp(attrname, "document-state") &&
       enumvalue >= 3 &&
-      enumvalue <= (3 + (int)(sizeof(ipp_document_states) /
-                              sizeof(ipp_document_states[0]))))
+      enumvalue < (3 + (int)(sizeof(ipp_document_states) /
+                            sizeof(ipp_document_states[0]))))
     return (ipp_document_states[enumvalue - 3]);
   else if (!strcmp(attrname, "finishings") ||
           !strcmp(attrname, "finishings-actual") ||
@@ -787,8 +787,8 @@ ippEnumString(const char *attrname, /* I - Attribute name */
           !strcmp(attrname, "finishings-supported"))
   {
     if (enumvalue >= 3 &&
-        enumvalue <= (3 + (int)(sizeof(ipp_finishings) /
-                                sizeof(ipp_finishings[0]))))
+        enumvalue < (3 + (int)(sizeof(ipp_finishings) /
+                              sizeof(ipp_finishings[0]))))
       return (ipp_finishings[enumvalue - 3]);
     else if (enumvalue >= 0x40000000 &&
              enumvalue <= (0x40000000 + (int)(sizeof(ipp_finishings_vendor) /
@@ -798,8 +798,8 @@ ippEnumString(const char *attrname, /* I - Attribute name */
   else if ((!strcmp(attrname, "job-collation-type") ||
             !strcmp(attrname, "job-collation-type-actual")) &&
            enumvalue >= 3 &&
-           enumvalue <= (3 + (int)(sizeof(ipp_job_collation_types) /
-                                   sizeof(ipp_job_collation_types[0]))))
+           enumvalue < (3 + (int)(sizeof(ipp_job_collation_types) /
+                                 sizeof(ipp_job_collation_types[0]))))
     return (ipp_job_collation_types[enumvalue - 3]);
   else if (!strcmp(attrname, "job-state") &&
           enumvalue >= IPP_JOB_PENDING && enumvalue <= IPP_JOB_COMPLETED)
@@ -811,16 +811,16 @@ ippEnumString(const char *attrname,       /* I - Attribute name */
             !strcmp(attrname, "orientation-requested-default") ||
             !strcmp(attrname, "orientation-requested-supported")) &&
            enumvalue >= 3 &&
-           enumvalue <= (3 + (int)(sizeof(ipp_orientation_requesteds) /
-                                   sizeof(ipp_orientation_requesteds[0]))))
+           enumvalue < (3 + (int)(sizeof(ipp_orientation_requesteds) /
+                                 sizeof(ipp_orientation_requesteds[0]))))
     return (ipp_orientation_requesteds[enumvalue - 3]);
   else if ((!strcmp(attrname, "print-quality") ||
             !strcmp(attrname, "print-quality-actual") ||
             !strcmp(attrname, "print-quality-default") ||
             !strcmp(attrname, "print-quality-supported")) &&
            enumvalue >= 3 &&
-           enumvalue <= (3 + (int)(sizeof(ipp_print_qualities) /
-                                   sizeof(ipp_print_qualities[0]))))
+           enumvalue < (3 + (int)(sizeof(ipp_print_qualities) /
+                                 sizeof(ipp_print_qualities[0]))))
     return (ipp_print_qualities[enumvalue - 3]);
   else if (!strcmp(attrname, "printer-state") &&
            enumvalue >= IPP_PRINTER_IDLE && enumvalue <= IPP_PRINTER_STOPPED)
index 462df8cb010645995a6622f2119ffedf55b2c1dc..7744ba3f0d565ed71b7d1b6213ba5a95b4952fa2 100644 (file)
@@ -3239,6 +3239,13 @@ ippReadIO(void       *src,               /* I - Data source */
              ipp->prev = ipp->current;
 
            attr = ipp->current = ipp_add_attr(ipp, NULL, ipp->curtag, IPP_TAG_ZERO, 1);
+           if (!attr)
+           {
+             _cupsSetHTTPError(HTTP_ERROR);
+             DEBUG_puts("1ippReadIO: unable to allocate attribute.");
+             _cupsBufferRelease((char *)buffer);
+             return (IPP_ERROR);
+           }
 
            DEBUG_printf(("2ippReadIO: membername, ipp->current=%p, ipp->prev=%p",
                          ipp->current, ipp->prev));
@@ -6364,6 +6371,7 @@ ipp_free_values(ipp_attribute_t *attr,    /* I - Attribute to free values from */
            _cupsStrFree(attr->values[0].string.language);
            attr->values[0].string.language = NULL;
          }
+         /* Fall through to other string values */
 
       case IPP_TAG_TEXT :
       case IPP_TAG_NAME :
index 97a388b84071d6307e1d59ad69ad0993cb42a701..bbd9507c3c72dc59363b72891a1f04b7a4a83852 100644 (file)
@@ -409,6 +409,7 @@ main(int  argc,                             /* I - Number of command-line args */
 
   if (srctype)
   {
+   /* sscanf return value already checked above */
     sscanf(srctype, "%15[^/]/%255s", super, type);
     if ((src = mimeType(mime, super, type)) == NULL)
     {
@@ -426,6 +427,7 @@ main(int  argc,                             /* I - Number of command-line args */
     return (1);
   }
 
+ /* sscanf return value already checked above */
   sscanf(dsttype, "%15[^/]/%255s", super, type);
   if (!_cups_strcasecmp(super, "printer"))
     dst = printer_type;
index 5bcb19bfbbd1a99c1fc1ecc93148565fd98258b2..2dc7bad3f337a85c401629cba49e3542661f5ee6 100644 (file)
@@ -4294,6 +4294,8 @@ load_request_root(void)
        else
          unload_job(job);
       }
+      else
+        free(job);
     }
 
   cupsDirClose(dir);
@@ -4385,7 +4387,7 @@ set_time(cupsd_job_t *job,                /* I - Job to update */
 
   if (!strcmp(name, "time-at-completed"))
   {
-    if (JobHistory < INT_MAX)
+    if (JobHistory < INT_MAX && attr)
       job->history_time = attr->values[0].integer + JobHistory;
     else
       job->history_time = INT_MAX;
@@ -4393,7 +4395,7 @@ set_time(cupsd_job_t *job,                /* I - Job to update */
     if (job->history_time < JobHistoryUpdate || !JobHistoryUpdate)
       JobHistoryUpdate = job->history_time;
 
-    if (JobFiles < INT_MAX)
+    if (JobFiles < INT_MAX && attr)
       job->file_time = attr->values[0].integer + JobFiles;
     else
       job->file_time = INT_MAX;