]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Another set of changes to resolve Coverity-detected issues.
authorMichael R Sweet <michael.r.sweet@gmail.com>
Tue, 2 Nov 2021 19:39:28 +0000 (15:39 -0400)
committerMichael R Sweet <michael.r.sweet@gmail.com>
Tue, 2 Nov 2021 19:39:28 +0000 (15:39 -0400)
18 files changed:
backend/dnssd.c
backend/snmp.c
cups/adminutil.c
cups/dest-options.c
cups/dest.c
cups/http-addrlist.c
cups/http-support.c
cups/http.c
cups/thread.c
filter/gziptoany.c
scheduler/cups-lpd.c
scheduler/ipp.c
scheduler/log.c
scheduler/type.c
tools/ippeveprinter.c
tools/ippeveps.c
tools/ippfind.c
tools/ipptool.c

index e570291780bc95713f93087c37a9163bf387edd2..610f3bc19e7a3620b63840cf79b455a9bbe1c19e 100644 (file)
@@ -887,7 +887,12 @@ get_device(cups_array_t *devices,  /* I - Device array */
   * Yes, add the device...
   */
 
-  device           = calloc(sizeof(cups_device_t), 1);
+  if ((device = calloc(sizeof(cups_device_t), 1)) == NULL)
+  {
+    perror("DEBUG: Out of memory adding a device");
+    return (NULL);
+  }
+
   device->name     = strdup(serviceName);
   device->domain   = strdup(replyDomain);
   device->type     = key.type;
index c7806572b104204fd66927793d4bb998fcaf5bb9..a90515e3d5e764989f632af5837d7b5a93fc5cc5 100644 (file)
@@ -619,22 +619,25 @@ get_interface_addresses(
     return (NULL);
 
   for (addr = addrs, first = NULL, last = NULL; addr; addr = addr->ifa_next)
+  {
     if ((addr->ifa_flags & IFF_BROADCAST) && addr->ifa_broadaddr &&
         addr->ifa_broadaddr->sa_family == AF_INET &&
        (!ifname || !strcmp(ifname, addr->ifa_name)))
     {
-      current = calloc(1, sizeof(http_addrlist_t));
-
-      memcpy(&(current->addr), addr->ifa_broadaddr,
-             sizeof(struct sockaddr_in));
+      if ((current = calloc(1, sizeof(http_addrlist_t))) != NULL)
+      {
+       memcpy(&(current->addr), addr->ifa_broadaddr,
+              sizeof(struct sockaddr_in));
 
-      if (!last)
-        first = current;
-      else
-        last->next = current;
+       if (!last)
+         first = current;
+       else
+         last->next = current;
 
-      last = current;
+       last = current;
+      }
     }
+  }
 
   freeifaddrs(addrs);
 
index 69b5f6c761b3bb99884445ebd03079631b2eb8a5..2f277cc5828e0094d176a983e0c9b207b4877999 100644 (file)
@@ -264,18 +264,17 @@ cupsAdminGetServerSettings(
            )
          remote_access = 1;
       }
-      else if (!_cups_strcasecmp(line, "Browsing"))
+      else if (!_cups_strcasecmp(line, "Browsing") && value)
       {
        browsing = !_cups_strcasecmp(value, "yes") ||
                   !_cups_strcasecmp(value, "on") ||
                   !_cups_strcasecmp(value, "true");
       }
-      else if (!_cups_strcasecmp(line, "LogLevel"))
+      else if (!_cups_strcasecmp(line, "LogLevel") && value)
       {
        debug_logging = !_cups_strncasecmp(value, "debug", 5);
       }
-      else if (!_cups_strcasecmp(line, "<Policy") &&
-               !_cups_strcasecmp(value, "default"))
+      else if (!_cups_strcasecmp(line, "<Policy") && value && !_cups_strcasecmp(value, "default"))
       {
        in_policy = 1;
       }
index 8c5fe666c457f13353141cc4b3ba5d7de1b1162b..61a14e14159d4c7aae69fd0e2be1238e27d41e7d 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Destination option/media support for CUPS.
  *
+ * Copyright © 2021 by OpenPrinting.
  * Copyright © 2012-2019 by Apple Inc.
  *
  * Licensed under Apache License v2.0.  See the file "LICENSE" for more
@@ -2512,32 +2513,27 @@ cups_get_media_db(http_t       *http,   /* I - Connection to destination */
     }
   }
 
-  if (best)
-  {
-   /*
-    * Return the matching size...
-    */
-
-    if (best->key)
-      strlcpy(size->media, best->key, sizeof(size->media));
-    else if (best->size_name)
-      strlcpy(size->media, best->size_name, sizeof(size->media));
-    else if (pwg && pwg->pwg)
-      strlcpy(size->media, pwg->pwg, sizeof(size->media));
-    else
-      strlcpy(size->media, "unknown", sizeof(size->media));
+ /*
+  * Return the matching size...
+  */
 
-    size->width  = best->width;
-    size->length = best->length;
-    size->bottom = best->bottom;
-    size->left   = best->left;
-    size->right  = best->right;
-    size->top    = best->top;
+  if (best->key)
+    strlcpy(size->media, best->key, sizeof(size->media));
+  else if (best->size_name)
+    strlcpy(size->media, best->size_name, sizeof(size->media));
+  else if (pwg->pwg)
+    strlcpy(size->media, pwg->pwg, sizeof(size->media));
+  else
+    strlcpy(size->media, "unknown", sizeof(size->media));
 
-    return (1);
-  }
+  size->width  = best->width;
+  size->length = best->length;
+  size->bottom = best->bottom;
+  size->left   = best->left;
+  size->right  = best->right;
+  size->top    = best->top;
 
-  return (0);
+  return (1);
 }
 
 
index 2ca2246d548588bc094af10e082df21167d7177a..e4edef1ff3cf550ba3fc511f0b83266356b1312e 100644 (file)
@@ -2831,14 +2831,16 @@ cups_dnssd_get_device(
                   !strcmp(regtype, "_ipps._tcp") ? "IPPS" : "IPP",
                   replyDomain));
 
-    device            = calloc(sizeof(_cups_dnssd_device_t), 1);
-    device->dest.name = _cupsStrAlloc(name);
-    device->domain    = _cupsStrAlloc(replyDomain);
-    device->regtype   = _cupsStrAlloc(regtype);
+    if ((device = calloc(sizeof(_cups_dnssd_device_t), 1)) != NULL)
+    {
+      device->dest.name = _cupsStrAlloc(name);
+      device->domain    = _cupsStrAlloc(replyDomain);
+      device->regtype   = _cupsStrAlloc(regtype);
 
-    device->dest.num_options = cupsAddOption("printer-info", serviceName, 0, &device->dest.options);
+      device->dest.num_options = cupsAddOption("printer-info", serviceName, 0, &device->dest.options);
 
-    cupsArrayAdd(data->devices, device);
+      cupsArrayAdd(data->devices, device);
+    }
   }
 
  /*
index dbe08d551c4868f31b0d18423959f083c81bdcd0..6e73464cd9084679a7f0849a112903c8b891b71d 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * HTTP address list routines for CUPS.
  *
+ * Copyright © 2021 by OpenPrinting.
  * Copyright © 2007-2021 by Apple Inc.
  * Copyright © 1997-2007 by Easy Software Products, all rights reserved.
  *
@@ -500,6 +501,9 @@ httpAddrGetList(const char *hostname,       /* I - Hostname, IP address, or NULL for p
   http_addrlist_t      *first,         /* First address in list */
                        *addr,          /* Current address in list */
                        *temp;          /* New address */
+  char                 ipv6[64],       /* IPv6 address */
+                       *ipv6zone;      /* Pointer to zone separator */
+  int                  ipv6len;        /* Length of IPv6 address */
   _cups_globals_t      *cg = _cupsGlobals();
                                        /* Global data */
 
@@ -569,9 +573,6 @@ httpAddrGetList(const char *hostname,       /* I - Hostname, IP address, or NULL for p
     struct addrinfo    hints,          /* Address lookup hints */
                        *results,       /* Address lookup results */
                        *current;       /* Current result */
-    char               ipv6[64],       /* IPv6 address */
-                       *ipv6zone;      /* Pointer to zone separator */
-    int                        ipv6len;        /* Length of IPv6 address */
     int                        error;          /* getaddrinfo() error */
 
 
index f442268da2895578e088289c50eca273823fa233..209235ee6a24ee48861a1c076ff07d122a4dba12 100644 (file)
@@ -2565,15 +2565,6 @@ http_resolve_cb(
   * Figure out the scheme from the full name...
   */
 
-  if (strstr(type, "_ipp."))
-    scheme = "ipp";
-  else if (strstr(type, "_printer."))
-    scheme = "lpd";
-  else if (strstr(type, "_pdl-datastream."))
-    scheme = "socket";
-  else
-    scheme = "riousbprint";
-
   if (!strncmp(type, "_ipps.", 6) || !strncmp(type, "_ipp-tls.", 9))
     scheme = "ipps";
   else if (!strncmp(type, "_ipp.", 5) || !strncmp(type, "_fax-ipp.", 9))
index ac0ba16d99eec079e16e5207da82299bf68529d4..66dd3b071ebfde5978810a313e84a701da9e547c 100644 (file)
@@ -3627,7 +3627,8 @@ http_add_field(http_t       *http,        /* I - HTTP connection */
 
   if (!valuelen)
   {
-    http->_fields[field][0] = '\0';
+    if (field < HTTP_FIELD_ACCEPT_ENCODING)
+      http->_fields[field][0] = '\0';
     return;
   }
 
index fcab9382676857751e56a42cf52ea87b6a0e4374..0e01cbfcd918c075c3ac3a34de2b3027df5dd897 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Threading primitives for CUPS.
  *
+ * Copyright © 2021 by OpenPrinting.
  * Copyright © 2009-2018 by Apple Inc.
  *
  * Licensed under Apache License v2.0.  See the file "LICENSE" for more
@@ -62,10 +63,10 @@ _cupsCondWait(_cups_cond_t  *cond,  /* I - Condition */
       abstime.tv_sec ++;
     };
 
-    pthread_cond_timedwait(cond, mutex, &abstime);
+    (void)pthread_cond_timedwait(cond, mutex, &abstime);
   }
   else
-    pthread_cond_wait(cond, mutex);
+    (void)pthread_cond_wait(cond, mutex);
 }
 
 
index 5d216e84fb4710c180edee8f65e2ec05c122469c..c2c8bc00d3dc938d5b3b38aec78f9f6203eb2a8c 100644 (file)
@@ -1,10 +1,12 @@
 /*
  * GZIP/raw pre-filter for CUPS.
  *
- * Copyright 2007-2015 by Apple Inc.
- * Copyright 1993-2007 by Easy Software Products.
+ * Copyright © 2021 by OpenPrinting.
+ * Copyright © 2007-2015 by Apple Inc.
+ * Copyright © 1993-2007 by Easy Software Products.
  *
- * Licensed under Apache License v2.0.  See the file "LICENSE" for more information.
+ * Licensed under Apache License v2.0.  See the file "LICENSE" for more
+ * information.
  */
 
 /*
@@ -46,9 +48,14 @@ main(int  argc,                              /* I - Number of command-line arguments */
   */
 
   if (!getenv("FINAL_CONTENT_TYPE"))
-    copies = atoi(argv[4]);
+  {
+    if ((copies = atoi(argv[4])) < 1)
+      copies = 1;
+  }
   else
+  {
     copies = 1;
+  }
 
  /*
   * Open the file...
index 6b2c9708fc8d6c44af0d5de977d2045766b87041..843065471e92705d1cba97062917cfcbc0ea59ed 100644 (file)
@@ -285,24 +285,19 @@ main(int  argc,                           /* I - Number of command-line arguments */
        break;
 
     case 0x05 : /* Remove jobs */
-        if (list)
-       {
-        /*
-         * Grab the agent and skip to the list of users and/or jobs.
-         */
+       /*
+       * Grab the agent and skip to the list of users and/or jobs.
+       */
 
-         agent = list;
+       agent = list;
 
-         for (; *list && !isspace(*list & 255); list ++);
-         while (isspace(*list & 255))
-           *list++ = '\0';
+       for (; *list && !isspace(*list & 255); list ++);
+       while (isspace(*list & 255))
+         *list++ = '\0';
 
-         syslog(LOG_INFO, "Remove jobs %s on %s by %s", list, dest, agent);
+       syslog(LOG_INFO, "Remove jobs %s on %s by %s", list, dest, agent);
 
-         status = (char)remove_jobs(dest, agent, list);
-        }
-       else
-         status = 1;
+       status = (char)remove_jobs(dest, agent, list);
 
        putchar(status);
        break;
index 2156a095c1ce9abc7f38c7971c14c985632f871a..5972b9955c829f7e1aea6d0c828e3bb7b73f18b2 100644 (file)
@@ -6790,6 +6790,7 @@ get_jobs(cupsd_client_t  *con,            /* I - Client connection */
     {
       send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist."),
                       job_ids->values[i].integer);
+      cupsArrayDelete(ra);
       return;
     }
 
index 41ddb4cb99978bb8f410c9fa4006e90383718e32..0fe7f3a2bcec719e92bc07d0e7a3ee5578f0086d 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Log file routines for the CUPS scheduler.
  *
+ * Copyright © 2021 by OpenPrinting.
  * Copyright © 2007-2018 by Apple Inc.
  * Copyright © 1997-2007 by Easy Software Products, all rights reserved.
  *
@@ -915,8 +916,11 @@ cupsdLogPage(cupsd_job_t *job,             /* I - Job being printed */
                          {
                            pwg_media_t *pwg = pwgMediaForSize(ippGetInteger(x_dimension, 0), ippGetInteger(y_dimension, 0));
                                        /* PWG media name */
-                           strlcpy(bufptr, pwg->pwg, sizeof(buffer) - (size_t)(bufptr - buffer));
-                           break;
+                           if (pwg)
+                           {
+                             strlcpy(bufptr, pwg->pwg, sizeof(buffer) - (size_t)(bufptr - buffer));
+                             break;
+                           }
                          }
                        }
 
index f547b835836b6a49f5a5a1f4344c29ba8b98085f..95ab46aa08ca6b62f34ace1fcfc46e6cb42c6abd 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * MIME typing routines for CUPS.
  *
+ * Copyright © 2021 by OpenPrinting.
  * Copyright © 2007-2019 by Apple Inc.
  * Copyright © 1997-2006 by Easy Software Products, all rights reserved.
  *
@@ -797,10 +798,16 @@ mime_check_rules(
            * Reload file buffer...
            */
 
-            cupsFileSeek(fb->fp, rules->offset);
-           fb->length = cupsFileRead(fb->fp, (char *)fb->buffer,
-                                     sizeof(fb->buffer));
-           fb->offset = rules->offset;
+            if (cupsFileSeek(fb->fp, rules->offset) < 0)
+            {
+              fb->length = 0;
+              fb->offset = 0;
+            }
+            else
+            {
+             fb->length = cupsFileRead(fb->fp, (char *)fb->buffer, sizeof(fb->buffer));
+             fb->offset = rules->offset;
+           }
 
            DEBUG_printf(("4mime_check_rules: MIME_MAGIC_ASCII fb->length=%d", fb->length));
          }
@@ -841,10 +848,16 @@ mime_check_rules(
            * Reload file buffer...
            */
 
-            cupsFileSeek(fb->fp, rules->offset);
-           fb->length = cupsFileRead(fb->fp, (char *)fb->buffer,
-                                     sizeof(fb->buffer));
-           fb->offset = rules->offset;
+            if (cupsFileSeek(fb->fp, rules->offset) < 0)
+            {
+              fb->length = 0;
+              fb->offset = 0;
+            }
+            else
+            {
+             fb->length = cupsFileRead(fb->fp, (char *)fb->buffer, sizeof(fb->buffer));
+             fb->offset = rules->offset;
+           }
 
            DEBUG_printf(("4mime_check_rules: MIME_MAGIC_PRINTABLE fb->length=%d", fb->length));
          }
@@ -890,10 +903,16 @@ mime_check_rules(
            * Reload file buffer...
            */
 
-            cupsFileSeek(fb->fp, rules->offset);
-           fb->length = cupsFileRead(fb->fp, (char *)fb->buffer,
-                                     sizeof(fb->buffer));
-           fb->offset = rules->offset;
+            if (cupsFileSeek(fb->fp, rules->offset) < 0)
+            {
+              fb->length = 0;
+              fb->offset = 0;
+            }
+            else
+            {
+             fb->length = cupsFileRead(fb->fp, (char *)fb->buffer, sizeof(fb->buffer));
+             fb->offset = rules->offset;
+           }
 
            DEBUG_printf(("4mime_check_rules: MIME_MAGIC_REGEX fb->length=%d", fb->length));
 
@@ -936,10 +955,16 @@ mime_check_rules(
            * Reload file buffer...
            */
 
-            cupsFileSeek(fb->fp, rules->offset);
-           fb->length = cupsFileRead(fb->fp, (char *)fb->buffer,
-                                     sizeof(fb->buffer));
-           fb->offset = rules->offset;
+            if (cupsFileSeek(fb->fp, rules->offset) < 0)
+            {
+              fb->length = 0;
+              fb->offset = 0;
+            }
+            else
+            {
+             fb->length = cupsFileRead(fb->fp, (char *)fb->buffer, sizeof(fb->buffer));
+             fb->offset = rules->offset;
+           }
 
            DEBUG_printf(("4mime_check_rules: MIME_MAGIC_STRING fb->length=%d", fb->length));
 
@@ -973,10 +998,16 @@ mime_check_rules(
            * Reload file buffer...
            */
 
-            cupsFileSeek(fb->fp, rules->offset);
-           fb->length = cupsFileRead(fb->fp, (char *)fb->buffer,
-                                     sizeof(fb->buffer));
-           fb->offset = rules->offset;
+            if (cupsFileSeek(fb->fp, rules->offset) < 0)
+            {
+              fb->length = 0;
+              fb->offset = 0;
+            }
+            else
+            {
+             fb->length = cupsFileRead(fb->fp, (char *)fb->buffer, sizeof(fb->buffer));
+             fb->offset = rules->offset;
+           }
 
            DEBUG_printf(("4mime_check_rules: MIME_MAGIC_ISTRING fb->length=%d", fb->length));
          }
@@ -1003,10 +1034,16 @@ mime_check_rules(
            * Reload file buffer...
            */
 
-            cupsFileSeek(fb->fp, rules->offset);
-           fb->length = cupsFileRead(fb->fp, (char *)fb->buffer,
-                                     sizeof(fb->buffer));
-           fb->offset = rules->offset;
+            if (cupsFileSeek(fb->fp, rules->offset) < 0)
+            {
+              fb->length = 0;
+              fb->offset = 0;
+            }
+            else
+            {
+             fb->length = cupsFileRead(fb->fp, (char *)fb->buffer, sizeof(fb->buffer));
+             fb->offset = rules->offset;
+           }
 
            DEBUG_printf(("4mime_check_rules: MIME_MAGIC_CHAR fb->length=%d", fb->length));
          }
@@ -1019,8 +1056,7 @@ mime_check_rules(
          if (fb->length < 1)
            result = 0;
          else
-           result = (fb->buffer[rules->offset - fb->offset] ==
-                         rules->value.charv);
+           result = (fb->buffer[rules->offset - fb->offset] == rules->value.charv);
          break;
 
       case MIME_MAGIC_SHORT :
@@ -1035,10 +1071,16 @@ mime_check_rules(
            * Reload file buffer...
            */
 
-            cupsFileSeek(fb->fp, rules->offset);
-           fb->length = cupsFileRead(fb->fp, (char *)fb->buffer,
-                                     sizeof(fb->buffer));
-           fb->offset = rules->offset;
+            if (cupsFileSeek(fb->fp, rules->offset) < 0)
+            {
+              fb->length = 0;
+              fb->offset = 0;
+            }
+            else
+            {
+             fb->length = cupsFileRead(fb->fp, (char *)fb->buffer, sizeof(fb->buffer));
+             fb->offset = rules->offset;
+           }
 
            DEBUG_printf(("4mime_check_rules: MIME_MAGIC_SHORT fb->length=%d", fb->length));
          }
@@ -1049,7 +1091,9 @@ mime_check_rules(
          */
 
          if (fb->length < 2)
+         {
            result = 0;
+         }
          else
          {
            bufptr = fb->buffer + rules->offset - fb->offset;
@@ -1070,10 +1114,16 @@ mime_check_rules(
            * Reload file buffer...
            */
 
-            cupsFileSeek(fb->fp, rules->offset);
-           fb->length = cupsFileRead(fb->fp, (char *)fb->buffer,
-                                     sizeof(fb->buffer));
-           fb->offset = rules->offset;
+            if (cupsFileSeek(fb->fp, rules->offset) < 0)
+            {
+              fb->length = 0;
+              fb->offset = 0;
+            }
+            else
+            {
+             fb->length = cupsFileRead(fb->fp, (char *)fb->buffer, sizeof(fb->buffer));
+             fb->offset = rules->offset;
+           }
 
            DEBUG_printf(("4mime_check_rules: MIME_MAGIC_INT fb->length=%d", fb->length));
          }
@@ -1084,7 +1134,9 @@ mime_check_rules(
          */
 
          if (fb->length < 4)
+         {
            result = 0;
+         }
          else
          {
            bufptr = fb->buffer + rules->offset - fb->offset;
@@ -1113,10 +1165,16 @@ mime_check_rules(
            * Reload file buffer...
            */
 
-            cupsFileSeek(fb->fp, rules->offset);
-           fb->length = cupsFileRead(fb->fp, (char *)fb->buffer,
-                                     sizeof(fb->buffer));
-           fb->offset = rules->offset;
+            if (cupsFileSeek(fb->fp, rules->offset) < 0)
+            {
+              fb->length = 0;
+              fb->offset = 0;
+            }
+            else
+            {
+             fb->length = cupsFileRead(fb->fp, (char *)fb->buffer, sizeof(fb->buffer));
+             fb->offset = rules->offset;
+           }
 
            DEBUG_printf(("4mime_check_rules: MIME_MAGIC_CONTAINS fb->length=%d", fb->length));
          }
@@ -1127,7 +1185,9 @@ mime_check_rules(
          */
 
          if ((rules->offset + rules->length) > (fb->offset + fb->length))
+         {
            result = 0;
+         }
          else
          {
            if (fb->length > rules->region)
index cf128dfbec8d457521146b301f6a2faa5e13cac2..2da5ed526c9885af85ff439d18e1979398987bdf 100644 (file)
@@ -7025,8 +7025,6 @@ process_job(ippeve_job_t *job)            /* I - Job */
 #endif /* !_WIN32 */
       job->state = IPP_JSTATE_ABORTED;
     }
-    else if (status < 0)
-      job->state = IPP_JSTATE_ABORTED;
     else
       fprintf(stderr, "[Job %d] Command \"%s\" completed successfully.\n", job->id, job->printer->command);
 
@@ -8049,6 +8047,8 @@ show_media(ippeve_client_t  *client)      /* I - Client connection */
   else
     html_printf(client, "</table>\n");
 
+  cupsFreeOptions(num_options, options);
+
   html_footer(client);
 
   return (1);
index 0550755b7fecc9cd47ae00c85418bcbc931031b2..8cebc5bf997267e9a8a49dc8bc8c3bb5cd4dfcb9 100644 (file)
@@ -73,7 +73,10 @@ main(int  argc,                              /* I - Number of command-line arguments */
 
   num_options = get_options(&options);
   if ((ipp_copies = getenv("IPP_COPIES")) != NULL)
-    copies = atoi(ipp_copies);
+  {
+    if ((copies = atoi(ipp_copies)) < 1)
+      copies = 1;
+  }
   else
     copies = 1;
 
@@ -952,7 +955,11 @@ ps_to_ps(const char    *filename,  /* I - Filename */
     if (!strncmp(line, "%%Page:", 7))
       break;
 
-    first_pos = ftell(fp);
+    if ((first_pos = ftell(fp)) < 0)
+    {
+      perror("DEBUG: ftell failed");
+      first_pos = 0;
+    }
 
     if (line[0] != '%')
       fputs(line, stdout);
index e0ea8567045ea2406f108de6f90ad351c190b276..7b5b7a919f8676ec1a7a6ae2457f2715dfaa6792 100644 (file)
@@ -2167,7 +2167,9 @@ get_service(cups_array_t *services,       /* I - Service array */
   * Yes, add the service...
   */
 
-  service           = calloc(sizeof(ippfind_srv_t), 1);
+  if ((service = calloc(sizeof(ippfind_srv_t), 1)) == NULL)
+    return (NULL);
+
   service->name     = strdup(serviceName);
   service->domain   = strdup(replyDomain);
   service->regtype  = strdup(regtype);
index b562d52e430f1800f9a7dde4d00e5e3d8a075099..64d38111f1c8d8b073af2842b9388e0f123af589 100644 (file)
@@ -4368,8 +4368,15 @@ token_cb(_ipp_file_t    *f,              /* I - IPP file data */
       * Name of test...
       */
 
-      _ippFileReadToken(f, temp, sizeof(temp));
-      _ippVarsExpand(vars, data->name, temp, sizeof(data->name));
+      if (_ippFileReadToken(f, temp, sizeof(temp)))
+      {
+        _ippVarsExpand(vars, data->name, temp, sizeof(data->name));
+      }
+      else
+      {
+       print_fatal_error(data, "Missing NAME string on line %d of \"%s\".", f->linenum, f->filename);
+       return (0);
+      }
     }
     else if (!_cups_strcasecmp(token, "PAUSE"))
     {