]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Add strlcat() and strlcpy() checks and emulation functions.
authormike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Thu, 16 May 2002 13:45:05 +0000 (13:45 +0000)
committermike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Thu, 16 May 2002 13:45:05 +0000 (13:45 +0000)
Rename all string emulation functions to cups_foo() to avoid
namespace collisions, etc.

Use strlcat() and strlcpy() instead of strncat() and strncpy() in
most cases.

git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@2414 7a7537e8-13f0-0310-91df-b6672ffda945

54 files changed:
CHANGES.txt
backend/ieee1394-linux.c
backend/ipp.c
backend/lpd.c
backend/parallel.c
backend/usb.c
berkeley/Dependencies
berkeley/lpq.c
cgi-bin/Dependencies
cgi-bin/admin.c
cgi-bin/cgi.h
cgi-bin/ipp-var.c
cgi-bin/template.c
config-scripts/cups-common.m4
config.h.in
cups/dest.c
cups/http.c
cups/language.c
cups/ppd.c
cups/snprintf.c
cups/string.c
cups/string.h
cups/usersys.c
cups/util.c
filter/Dependencies
filter/imagetops.c
filter/imagetoraster.c
pstoraster/gdevcups.c
scheduler/Dependencies
scheduler/auth.c
scheduler/banners.c
scheduler/cert.c
scheduler/classes.c
scheduler/client.c
scheduler/conf.c
scheduler/cups-lpd.c
scheduler/devices.c
scheduler/dirsvc.c
scheduler/filter.c
scheduler/ipp.c
scheduler/job.c
scheduler/log.c
scheduler/main.c
scheduler/mime.c
scheduler/network.c
scheduler/ppds.c
scheduler/printers.c
scheduler/quotas.c
scheduler/type.c
systemv/accept.c
systemv/cancel.c
systemv/cupsaddsmb.c
systemv/lpadmin.c
test/ipptest.c

index 788b1284bbcace551585a609367ef0e7d12de5dd..16db9b6bb7e5ed1762482c3d91f97572df08811e 100644 (file)
@@ -1,10 +1,12 @@
-CHANGES.txt - 05/15/2002
+CHANGES.txt - 05/16/2002
 ------------------------
 
 CHANGES IN CUPS V1.1.15
 
        - Updated the CUPS license agreement for the new MacOS
          and OpenSSL license exceptions.
+       - Now use strlcat() and strlcpy() (or emulation
+         functions) for easier string/buffer protection.
        - The auto-generated printcap/printers.conf files now
          have a small comment header explaining where the file
          comes from...
index b79f989b7e1cf6351be5e00c4f7af50a1a43d19b..27b5bd2bd780ee08da1292f222470974752fb414 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: ieee1394-linux.c,v 1.1 2002/05/04 16:58:23 mike Exp $"
+ * "$Id: ieee1394-linux.c,v 1.2 2002/05/16 13:44:50 mike Exp $"
  *
  *   Linux IEEE-1394 glue for the Common UNIX Printing System (CUPS).
  *
@@ -645,8 +645,8 @@ ieee1394_list(int *num_devices)             /* O - Number of printers */
                * Use the description directly...
                */
 
-               strncpy(nodes[num_nodes].make_model, idptr,
-                       sizeof(nodes[num_nodes].make_model) - 1);
+               strlcpy(nodes[num_nodes].make_model, idptr,
+                       sizeof(nodes[num_nodes].make_model));
               }
              else
              {
@@ -847,5 +847,5 @@ ieee1394_error(void)
 
 
 /*
- * End of "$Id: ieee1394-linux.c,v 1.1 2002/05/04 16:58:23 mike Exp $".
+ * End of "$Id: ieee1394-linux.c,v 1.2 2002/05/16 13:44:50 mike Exp $".
  */
index 3999eeebbc5f18a415b5615a9e7bf417d757dbf9..351aab8396c3f6b784a0225394981a6de83db3bf 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: ipp.c,v 1.61 2002/04/24 19:54:24 mike Exp $"
+ * "$Id: ipp.c,v 1.62 2002/05/16 13:44:50 mike Exp $"
  *
  *   IPP backend for the Common UNIX Printing System (CUPS).
  *
@@ -169,10 +169,7 @@ main(int  argc,            /* I - Number of command-line arguments (6 or 7) */
     close(fd);
   }
   else
-  {
-    strncpy(filename, argv[6], sizeof(filename) - 1);
-    filename[sizeof(filename) - 1] = '\0';
-  }
+    strlcpy(filename, argv[6], sizeof(filename));
 
  /*
   * Extract the hostname and printer name from the URI...
@@ -820,5 +817,5 @@ report_printer_state(ipp_t *ipp)    /* I - IPP response */
 
 
 /*
- * End of "$Id: ipp.c,v 1.61 2002/04/24 19:54:24 mike Exp $".
+ * End of "$Id: ipp.c,v 1.62 2002/05/16 13:44:50 mike Exp $".
  */
index 07d83417f77d2d44ce396f1c332b975176c4da04..4111293c2958ac362278612220afaa3edeab3dfd 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: lpd.c,v 1.35 2002/03/25 17:13:55 mike Exp $"
+ * "$Id: lpd.c,v 1.36 2002/05/16 13:44:50 mike Exp $"
  *
  *   Line Printer Daemon backend for the Common UNIX Printing System (CUPS).
  *
@@ -168,10 +168,7 @@ main(int  argc,            /* I - Number of command-line arguments (6 or 7) */
     close(fd);
   }
   else
-  {
-    strncpy(filename, argv[6], sizeof(filename) - 1);
-    filename[sizeof(filename) - 1] = '\0';
-  }
+    strlcpy(filename, argv[6], sizeof(filename));
 
  /*
   * Extract the hostname and printer name from the URI...
@@ -274,8 +271,7 @@ main(int  argc,             /* I - Number of command-line arguments (6 or 7) */
   * Sanitize the document title...
   */
 
-  strncpy(title, argv[3], sizeof(title) - 1);
-  title[sizeof(title) - 1] = '\0';
+  strlcpy(title, argv[3], sizeof(title));
 
   for (ptr = title; *ptr; ptr ++)
     if (!isalnum(*ptr) && !isspace(*ptr))
@@ -764,5 +760,5 @@ rresvport(int *port)                /* IO - Port number to bind to */
 #endif /* !HAVE_RRESVPORT */
 
 /*
- * End of "$Id: lpd.c,v 1.35 2002/03/25 17:13:55 mike Exp $".
+ * End of "$Id: lpd.c,v 1.36 2002/05/16 13:44:50 mike Exp $".
  */
index 729a7d6adafa463a9828c6d304ca258c5848498d..092ff6818fb508de50f436ff6aadbf4847cfe2f1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: parallel.c,v 1.42 2002/03/25 18:10:08 mike Exp $"
+ * "$Id: parallel.c,v 1.43 2002/05/16 13:44:50 mike Exp $"
  *
  *   Parallel port backend for the Common UNIX Printing System (CUPS).
  *
@@ -395,10 +395,10 @@ list_devices(void)
 
         if (strncmp(line, "MODEL:", 6) == 0 &&
            strncmp(line, "MODEL:Unknown", 13) != 0)
-         strncpy(model, line + 6, sizeof(model) - 1);
+         strlcpy(model, line + 6, sizeof(model));
        else if (strncmp(line, "MANUFACTURER:", 13) == 0 &&
                 strncmp(line, "MANUFACTURER:Unknown", 20) != 0)
-         strncpy(make, line + 13, sizeof(make) - 1);
+         strlcpy(make, line + 13, sizeof(make));
       }
 
       fclose(probe);
@@ -658,5 +658,5 @@ list_devices(void)
 
 
 /*
- * End of "$Id: parallel.c,v 1.42 2002/03/25 18:10:08 mike Exp $".
+ * End of "$Id: parallel.c,v 1.43 2002/05/16 13:44:50 mike Exp $".
  */
index c5d947690e3a3a6c9a9daba56aa8bb36aea62c52..943942e678517438711bc46b37ee6dbc4a735832 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: usb.c,v 1.29 2002/03/25 18:10:08 mike Exp $"
+ * "$Id: usb.c,v 1.30 2002/05/16 13:44:50 mike Exp $"
  *
  *   USB port backend for the Common UNIX Printing System (CUPS).
  *
@@ -342,12 +342,12 @@ list_devices(void)
 
         if (strncmp(line, "S:  Manufacturer=", 17) == 0)
        {
-         strncpy(make, line + 17, sizeof(make) - 1);
+         strlcpy(make, line + 17, sizeof(make));
          if (strcmp(make, "Hewlett-Packard") == 0)
            strcpy(make, "HP");
        }
         else if (strncmp(line, "S:  Product=", 12) == 0)
-         strncpy(model, line + 12, sizeof(model) - 1);
+         strlcpy(model, line + 12, sizeof(model));
       }
       else if (strncmp(line, "I:", 2) == 0 &&
                (strstr(line, "Driver=printer") != NULL ||
@@ -460,5 +460,5 @@ list_devices(void)
 
 
 /*
- * End of "$Id: usb.c,v 1.29 2002/03/25 18:10:08 mike Exp $".
+ * End of "$Id: usb.c,v 1.30 2002/05/16 13:44:50 mike Exp $".
  */
index 046bab6b7def2f8b29642b0cbb3d40c08fa28b77..0915065b5d129d9cacf059bff3cc44a4cbc95c2f 100644 (file)
@@ -2,8 +2,9 @@
 
 lpc.o: ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/md5.h
 lpc.o: ../cups/ppd.h ../cups/language.h ../cups/debug.h
-lpq.o: ../config.h ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/md5.h
-lpq.o: ../cups/ppd.h ../cups/language.h ../cups/debug.h
+lpq.o: ../cups/string.h ../config.h ../cups/cups.h ../cups/ipp.h
+lpq.o: ../cups/http.h ../cups/md5.h ../cups/ppd.h ../cups/language.h
+lpq.o: ../cups/debug.h
 lpr.o: ../config.h ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/md5.h
 lpr.o: ../cups/ppd.h
 lprm.o: ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/md5.h
index 1b97b601801cd8c38ee56b8938e755144969d315..8aadce0ae9b64302a20f2ad3045fb05a812a4d5b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: lpq.c,v 1.20 2002/01/02 17:58:35 mike Exp $"
+ * "$Id: lpq.c,v 1.21 2002/05/16 13:44:51 mike Exp $"
  *
  *   "lpq" command for the Common UNIX Printing System (CUPS).
  *
@@ -38,8 +38,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <ctype.h>
-#include <config.h>
+#include <cups/string.h>
 #include <cups/cups.h>
 #include <cups/language.h>
 #include <cups/debug.h>
@@ -415,10 +414,7 @@ show_jobs(http_t     *http,        /* I - HTTP connection to server */
          snprintf(namestr, sizeof(namestr), "%d copies of %s", jobcopies,
                   jobname);
        else
-       {
-         strncpy(namestr, jobname, sizeof(namestr) - 1);
-         namestr[sizeof(namestr) - 1] = '\0';
-       }
+         strlcpy(namestr, jobname, sizeof(namestr));
 
         printf("%s: %-34.34s[job %d localhost]\n", jobuser, rankstr, jobid);
         printf("        %-40.40s%d bytes\n", namestr, jobsize);
@@ -538,5 +534,5 @@ show_printer(http_t     *http,      /* I - HTTP connection to server */
 
 
 /*
- * End of "$Id: lpq.c,v 1.20 2002/01/02 17:58:35 mike Exp $".
+ * End of "$Id: lpq.c,v 1.21 2002/05/16 13:44:51 mike Exp $".
  */
index 778b3f713067ed320039ca573815fb4ee5212068..d69abebfa0e556c2f5eba2c8b67ca44218d3c436 100644 (file)
@@ -1,11 +1,11 @@
 # DO NOT DELETE
 
-html.o: cgi.h
+html.o: cgi.h ../cups/string.h ../config.h
 ipp-var.o: ipp-var.h ../cups/cups.h ../cups/ipp.h ../cups/http.h
 ipp-var.o: ../cups/md5.h ../cups/ppd.h ../cups/debug.h ../cups/language.h
 ipp-var.o: ../cups/string.h ../config.h cgi.h
-template.o: cgi.h
-var.o: cgi.h
+template.o: cgi.h ../cups/string.h ../config.h
+var.o: cgi.h ../cups/string.h ../config.h
 admin.o: ipp-var.h ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/md5.h
 admin.o: ../cups/ppd.h ../cups/debug.h ../cups/language.h ../cups/string.h
 admin.o: ../config.h cgi.h
index 689e5c1795c7b1fbe05add9ec2d43b4d539a6535..84149079e1768855dd0748b0f3582c5eca8eb39e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: admin.c,v 1.26 2002/03/25 17:51:17 mike Exp $"
+ * "$Id: admin.c,v 1.27 2002/05/16 13:44:51 mike Exp $"
  *
  *   Administration CGI for the Common UNIX Printing System (CUPS).
  *
@@ -635,8 +635,7 @@ do_am_printer(http_t      *http,    /* I - HTTP connection */
     if (oldinfo &&
         (attr = ippFindAttribute(oldinfo, "device-uri", IPP_TAG_URI)) != NULL)
     {
-      strncpy(uri, attr->values[0].string.text, sizeof(uri) - 1);
-      uri[sizeof(uri) - 1] = '\0';
+      strlcpy(uri, attr->values[0].string.text, sizeof(uri));
       if ((uriptr = strchr(uri, ':')) != NULL && strncmp(uriptr, "://", 3) == 0)
         *uriptr = '\0';
 
@@ -789,8 +788,7 @@ do_am_printer(http_t      *http,    /* I - HTTP connection */
        * Let the user choose a model...
        */
 
-        strncpy(make, var, sizeof(make) - 1);
-       make[sizeof(make) - 1] = '\0';
+        strlcpy(make, var, sizeof(make));
 
         ippSetCGIVars(response, "ppd-make", make);
        cgiCopyTemplateLang(stdout, TEMPLATES, "choose-model.tmpl",
@@ -852,8 +850,7 @@ do_am_printer(http_t      *http,    /* I - HTTP connection */
     ippAddString(request, IPP_TAG_PRINTER, IPP_TAG_NAME, "ppd-name",
                  NULL, cgiGetVariable("PPD_NAME"));
 
-    strncpy(uri, cgiGetVariable("DEVICE_URI"), sizeof(uri) - 1);
-    uri[sizeof(uri) - 1] = '\0';
+    strlcpy(uri, cgiGetVariable("DEVICE_URI"), sizeof(uri));
     if (strncmp(uri, "serial:", 7) == 0)
     {
      /*
@@ -1146,8 +1143,7 @@ do_config_printer(http_t      *http,      /* I - HTTP connection */
         * Get default option name...
        */
 
-        strncpy(keyword, line + 8, sizeof(keyword) - 1);
-       keyword[sizeof(keyword) - 1] = '\0';
+        strlcpy(keyword, line + 8, sizeof(keyword));
 
        for (keyptr = keyword; *keyptr; keyptr ++)
          if (*keyptr == ':' || isspace(*keyptr))
@@ -1600,5 +1596,5 @@ get_line(char *buf,       /* I - Line buffer */
 
 
 /*
- * End of "$Id: admin.c,v 1.26 2002/03/25 17:51:17 mike Exp $".
+ * End of "$Id: admin.c,v 1.27 2002/05/16 13:44:51 mike Exp $".
  */
index 01da2fe0228ee50ba3dac35deaa56e23372824dc..1b6f148321eef7a5372bc734ec6eb50187afe226 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: cgi.h,v 1.14 2002/01/27 21:16:09 mike Exp $"
+ * "$Id: cgi.h,v 1.15 2002/05/16 13:44:52 mike Exp $"
  *
  *   CGI support library definitions.
  *
 
 #  include <stdio.h>
 #  include <stdlib.h>
-#  include <string.h>
-#  include <ctype.h>
 #  include <time.h>
 
+#  include <cups/string.h>
+
 #  ifdef WIN32
 #    include <direct.h>
 #    include <io.h>
 #  endif /* WIN32 */
 
 
-/*
- * Stuff for WIN32 and OS/2...
- */
-
-#  if defined(WIN32) || defined(__EMX__)
-#    define strcasecmp  stricmp
-#    define strncasecmp strnicmp
-#  endif /* WIN32 || __EMX__ */
-
-
 /*
  * Prototypes...
  */
@@ -92,5 +82,5 @@ extern void           cgiSetCookie(const char *name, const char *value,
 #endif /* !_CGI_H_ */
 
 /*
- * End of "$Id: cgi.h,v 1.14 2002/01/27 21:16:09 mike Exp $".
+ * End of "$Id: cgi.h,v 1.15 2002/05/16 13:44:52 mike Exp $".
  */
index 52514582e1b0b3bb42ce30cc7ba93a94bb9c9e27..2cb28f5b5ffbe2ba0bd3b37bfd06c595b4ee000d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: ipp-var.c,v 1.27 2002/04/08 16:28:31 mike Exp $"
+ * "$Id: ipp-var.c,v 1.28 2002/05/16 13:44:52 mike Exp $"
  *
  *   IPP variable routines for the Common UNIX Printing System (CUPS).
  *
@@ -177,14 +177,13 @@ ippSetCGIVars(ipp_t      *response,       /* I - Response data to be copied... */
       * Copy values...
       */
 
-      value[0]                 = '\0'; /* Initially an empty string */
-      value[sizeof(value) - 1] = '\0'; /* In case string gets full */
-      valptr                   = value; /* Start at the beginning */
+      value[0] = '\0'; /* Initially an empty string */
+      valptr   = value; /* Start at the beginning */
 
       for (i = 0; i < attr->num_values; i ++)
       {
        if (i)
-         strncat(valptr, ",", sizeof(value) - (valptr - value) - 1);
+         strlcat(valptr, ",", sizeof(value) - (valptr - value));
 
        valptr += strlen(valptr);
 
@@ -209,7 +208,7 @@ ippSetCGIVars(ipp_t      *response, /* I - Response data to be copied... */
              break;
 
          case IPP_TAG_NOVALUE :
-             strncat(valptr, "novalue", sizeof(value) - (valptr - value) - 1);
+             strlcat(valptr, "novalue", sizeof(value) - (valptr - value));
              break;
 
          case IPP_TAG_RANGE :
@@ -245,8 +244,7 @@ ippSetCGIVars(ipp_t      *response, /* I - Response data to be copied... */
                    * Make URI relative to the current server...
                    */
 
-                    strncpy(uri, resource, sizeof(uri) - 1);
-                   uri[sizeof(uri) - 1] = '\0';
+                    strlcpy(uri, resource, sizeof(uri));
                  }
                  else
                  {
@@ -264,7 +262,7 @@ ippSetCGIVars(ipp_t      *response, /* I - Response data to be copied... */
                               hostname, port, resource);
                   }
 
-                 strncat(valptr, uri, sizeof(value) - (valptr - value) - 1);
+                 strlcat(valptr, uri, sizeof(value) - (valptr - value));
                  break;
                }
               }
@@ -275,8 +273,8 @@ ippSetCGIVars(ipp_t      *response, /* I - Response data to be copied... */
          case IPP_TAG_KEYWORD :
          case IPP_TAG_CHARSET :
          case IPP_TAG_LANGUAGE :
-             strncat(valptr, attr->values[i].string.text,
-                     sizeof(value) - (valptr - value) - 1);
+             strlcat(valptr, attr->values[i].string.text,
+                     sizeof(value) - (valptr - value));
              break;
 
           default :
@@ -298,5 +296,5 @@ ippSetCGIVars(ipp_t      *response, /* I - Response data to be copied... */
 
 
 /*
- * End of "$Id: ipp-var.c,v 1.27 2002/04/08 16:28:31 mike Exp $".
+ * End of "$Id: ipp-var.c,v 1.28 2002/05/16 13:44:52 mike Exp $".
  */
index a4b621ae8214cce4d69f7968feee6e3ac58af2c6..a79c5665805d30c8110a221f12a6d256fac559ab 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: template.c,v 1.25 2002/01/02 17:58:37 mike Exp $"
+ * "$Id: template.c,v 1.26 2002/05/16 13:44:52 mike Exp $"
  *
  *   CGI template function.
  *
@@ -373,28 +373,19 @@ cgi_copy(FILE *out,               /* I - Output file */
              if ((innerval = cgiGetArray(innername, atoi(innerptr) - 1)) == NULL)
                *s = '\0';
              else
-             {
-               strncpy(s, innerval, sizeof(compare) - (s - compare) - 1);
-               compare[sizeof(compare) - 1] = '\0';
-             }
+               strlcpy(s, innerval, sizeof(compare) - (s - compare));
            }
            else if (innername[0] == '?')
            {
              if ((innerval = cgiGetArray(innername + 1, element)) == NULL)
                *s = '\0';
              else
-             {
-               strncpy(s, innerval, sizeof(compare) - (s - compare) - 1);
-               compare[sizeof(compare) - 1] = '\0';
-             }
+               strlcpy(s, innerval, sizeof(compare) - (s - compare));
             }
            else if ((innerval = cgiGetArray(innername, element)) == NULL)
              snprintf(s, sizeof(s), "{%s}", innername);
            else
-           {
-             strncpy(s, innerval, sizeof(compare) - (s - compare) - 1);
-             compare[sizeof(compare) - 1] = '\0';
-           }
+             strlcpy(s, innerval, sizeof(compare) - (s - compare));
 
             s += strlen(s);
          }
@@ -497,5 +488,5 @@ cgi_puts(const char *s,
 
 
 /*
- * End of "$Id: template.c,v 1.25 2002/01/02 17:58:37 mike Exp $".
+ * End of "$Id: template.c,v 1.26 2002/05/16 13:44:52 mike Exp $".
  */
index cd166608ab316e0fdcc03637b41ee0e819db757d..06e28433e27ab73e14ce98bcbeb60cb465d784e2 100644 (file)
@@ -1,5 +1,5 @@
 dnl
-dnl "$Id: cups-common.m4,v 1.16 2002/03/08 19:48:58 mike Exp $"
+dnl "$Id: cups-common.m4,v 1.17 2002/05/16 13:44:53 mike Exp $"
 dnl
 dnl   Common configuration stuff for the Common UNIX Printing System (CUPS).
 dnl
@@ -91,7 +91,7 @@ AC_CHECK_HEADER(usersec.h,AC_DEFINE(HAVE_USERSEC_H))
 AC_CHECK_HEADER(sys/ioctl.h,AC_DEFINE(HAVE_SYS_IOCTL_H))
 
 dnl Checks for string functions.
-AC_CHECK_FUNCS(strdup strcasecmp strncasecmp)
+AC_CHECK_FUNCS(strdup strcasecmp strncasecmp strlcat strlcpy)
 if test "$uname" = "HP-UX" -a "$uversion" = "1020"; then
        echo Forcing snprintf emulation for HP-UX.
 else
@@ -152,5 +152,5 @@ esac
 AC_SUBST(ARFLAGS)
 
 dnl
-dnl End of "$Id: cups-common.m4,v 1.16 2002/03/08 19:48:58 mike Exp $".
+dnl End of "$Id: cups-common.m4,v 1.17 2002/05/16 13:44:53 mike Exp $".
 dnl
index 31cd94580b1453035b01b33d5dd6ae1aef43c6db..94bb7ceefdfaf5456ee24b29d95b74febca4b591 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: config.h.in,v 1.56 2002/03/28 21:48:43 mike Exp $"
+ * "$Id: config.h.in,v 1.57 2002/05/16 13:44:49 mike Exp $"
  *
  *   Configuration file for the Common UNIX Printing System (CUPS).
  *
 #undef HAVE_STRDUP
 #undef HAVE_STRCASECMP
 #undef HAVE_STRNCASECMP
+#undef HAVE_STRLCAT
+#undef HAVE_STRLCPY
 
 
 /*
 
 
 /*
- * End of "$Id: config.h.in,v 1.56 2002/03/28 21:48:43 mike Exp $".
+ * End of "$Id: config.h.in,v 1.57 2002/05/16 13:44:49 mike Exp $".
  */
index c050e0aa3dddd87aff2e65c5b832c7d382984020..25e9cf377a464ff7e66d03427e91f02159b02a75 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: dest.c,v 1.30 2002/03/22 14:21:42 mike Exp $"
+ * "$Id: dest.c,v 1.31 2002/05/16 13:44:53 mike Exp $"
  *
  *   User-defined destination (and option) support for the Common UNIX
  *   Printing System (CUPS).
@@ -265,8 +265,7 @@ cupsGetDests(cups_dest_t **dests)   /* O - Destinations */
     * Grab printer and instance name...
     */
 
-    strncpy(name, defprinter, sizeof(name) - 1);
-    name[sizeof(name) - 1] = '\0';
+    strlcpy(name, defprinter, sizeof(name));
 
     if ((instance = strchr(name, '/')) != NULL)
       *instance++ = '\0';
@@ -795,5 +794,5 @@ cups_get_sdests(ipp_op_t    op,             /* I - get-printers or get-classes */
 
 
 /*
- * End of "$Id: dest.c,v 1.30 2002/03/22 14:21:42 mike Exp $".
+ * End of "$Id: dest.c,v 1.31 2002/05/16 13:44:53 mike Exp $".
  */
index db97bc785d5e4705a9184880d1f7ba6b9eb03272..9006ba3d484dc14b92b2038483ab21ddb96c622d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: http.c,v 1.96 2002/04/09 19:27:06 mike Exp $"
+ * "$Id: http.c,v 1.97 2002/05/16 13:44:53 mike Exp $"
  *
  *   HTTP routines for the Common UNIX Printing System (CUPS) scheduler.
  *
@@ -394,7 +394,7 @@ httpConnectEncrypt(const char *host,        /* I - Host to connect to */
   * Copy the hostname and port and then "reconnect"...
   */
 
-  strncpy(http->hostname, host, sizeof(http->hostname) - 1);
+  strlcpy(http->hostname, host, sizeof(http->hostname));
   http->hostaddr.sin_family = hostaddr->h_addrtype;
 #ifdef WIN32
   http->hostaddr.sin_port   = htons((u_short)port);
@@ -415,7 +415,7 @@ httpConnectEncrypt(const char *host,        /* I - Host to connect to */
   * Loop through the addresses we have until one of them connects...
   */
 
-  strncpy(http->hostname, host, sizeof(http->hostname) - 1);
+  strlcpy(http->hostname, host, sizeof(http->hostname));
 
   for (i = 0; hostaddr->h_addr_list[i]; i ++)
   {
@@ -719,8 +719,7 @@ httpSeparate(const char *uri,               /* I - Universal Resource Identifier */
   * longer than HTTP_MAX_URI characters long...
   */
 
-  strncpy(safeuri, uri, sizeof(safeuri));
-  safeuri[sizeof(safeuri) - 1] = '\0';
+  strlcpy(safeuri, uri, sizeof(safeuri));
 
   uri = safeuri;
 
@@ -759,8 +758,7 @@ httpSeparate(const char *uri,               /* I - Universal Resource Identifier */
     {
       if ((ptr = strchr(host, '/')) != NULL)
       {
-       strncpy(resource, ptr, HTTP_MAX_URI);
-       resource[HTTP_MAX_URI - 1] = '\0';
+       strlcpy(resource, ptr, HTTP_MAX_URI);
        *ptr = '\0';
       }
       else
@@ -775,10 +773,7 @@ httpSeparate(const char *uri,              /* I - Universal Resource Identifier */
        *port = strtol(uri, (char **)&uri, 10);
 
        if (*uri == '/')
-       {
-          strncpy(resource, uri, HTTP_MAX_URI);
-          resource[HTTP_MAX_URI - 1] = '\0';
-       }
+          strlcpy(resource, uri, HTTP_MAX_URI);
       }
       else
        *port = 631;
@@ -788,10 +783,7 @@ httpSeparate(const char *uri,              /* I - Universal Resource Identifier */
       return;
     }
     else
-    {
-      strncpy(method, host, 31);
-      method[31] = '\0';
-    }
+      strlcpy(method, host, 32);
   }
 
  /*
@@ -800,8 +792,7 @@ httpSeparate(const char *uri,               /* I - Universal Resource Identifier */
 
   if (strncmp(uri, "//", 2) != 0)
   {
-    strncpy(resource, uri, 1023);
-    resource[1023] = '\0';
+    strlcpy(resource, uri, HTTP_MAX_URI);
 
     username[0] = '\0';
     host[0]     = '\0';
@@ -889,8 +880,7 @@ httpSeparate(const char *uri,               /* I - Universal Resource Identifier */
   * The remaining portion is the resource string...
   */
 
-  strncpy(resource, uri, HTTP_MAX_URI);
-  resource[HTTP_MAX_URI - 1] = '\0';
+  strlcpy(resource, uri, HTTP_MAX_URI);
 }
 
 
@@ -1032,8 +1022,7 @@ httpSetField(http_t       *http,  /* I - HTTP data */
       value == NULL)
     return;
 
-  strncpy(http->fields[field], value, HTTP_MAX_VALUE - 1);
-  http->fields[field][HTTP_MAX_VALUE - 1] = '\0';
+  strlcpy(http->fields[field], value, HTTP_MAX_VALUE);
 }
 
 
@@ -2280,5 +2269,5 @@ http_upgrade(http_t *http)        /* I - HTTP data */
 
 
 /*
- * End of "$Id: http.c,v 1.96 2002/04/09 19:27:06 mike Exp $".
+ * End of "$Id: http.c,v 1.97 2002/05/16 13:44:53 mike Exp $".
  */
index 514f0fa86fb2b2f47cfd1842446b09658b71bb6b..ad3d627f86c2ab8353d91938ec4d8a86d02765ea 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: language.c,v 1.26 2002/03/01 19:53:29 mike Exp $"
+ * "$Id: language.c,v 1.27 2002/05/16 13:44:54 mike Exp $"
  *
  *   I18N/language support for the Common UNIX Printing System (CUPS).
  *
@@ -176,8 +176,7 @@ cupsLangGet(const char *language) /* I - Language or locale */
     * Copy the locale string over safely...
     */
 
-    strncpy(langname, language, sizeof(langname) - 1);
-    langname[sizeof(langname) - 1] = '\0';
+    strlcpy(langname, language, sizeof(langname));
   }
 
   if (strlen(langname) < 2)
@@ -214,8 +213,7 @@ cupsLangGet(const char *language) /* I - Language or locale */
       * Add charset...
       */
 
-      strncpy(real + count, langname + count, sizeof(real) - count - 1);
-      langname[count] = '\0';
+      strlcpy(real + count, langname + count, sizeof(real) - count);
       count += strlen(real + count);
 
      /*
@@ -289,10 +287,7 @@ cupsLangGet(const char *language) /* I - Language or locale */
   */
 
   if (fp == NULL)
-  {
-    strncpy(line, lang_default[0], sizeof(line) - 1);
-    line[sizeof(line) - 1] = '\0';
-  }
+    strlcpy(line, lang_default[0], sizeof(line));
   else if (fgets(line, sizeof(line), fp) == NULL)
   {
    /*
@@ -349,8 +344,7 @@ cupsLangGet(const char *language) /* I - Language or locale */
   */
 
   lang->used ++;
-  strncpy(lang->language, langname, sizeof(lang->language) - 1);
-  lang->language[sizeof(lang->language) - 1] = '\0';
+  strlcpy(lang->language, langname, sizeof(lang->language));
 
   for (i = 0; i < (sizeof(lang_encodings) / sizeof(lang_encodings[0])); i ++)
     if (strcmp(lang_encodings[i], line) == 0)
@@ -377,8 +371,7 @@ cupsLangGet(const char *language) /* I - Language or locale */
       if (lang_default[count] == NULL)
         break;
 
-      strncpy(line, lang_default[count], sizeof(line) - 1);
-      /* Already set last byte to 0 above... */
+      strlcpy(line, lang_default[count], sizeof(line));
     }
     else if (fgets(line, sizeof(line), fp) == NULL)
       break;
@@ -429,5 +422,5 @@ cupsLangGet(const char *language) /* I - Language or locale */
 
 
 /*
- * End of "$Id: language.c,v 1.26 2002/03/01 19:53:29 mike Exp $".
+ * End of "$Id: language.c,v 1.27 2002/05/16 13:44:54 mike Exp $".
  */
index c6bdfa8ffa76259ad56d09f19eda1c631ddee782..d11faacbad7a6158ef86981b2ab5092e528770b2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: ppd.c,v 1.67 2002/05/14 16:13:48 mike Exp $"
+ * "$Id: ppd.c,v 1.68 2002/05/16 13:44:54 mike Exp $"
  *
  *   PPD file routines for the Common UNIX Printing System (CUPS).
  *
@@ -310,7 +310,7 @@ ppd_get_group(ppd_file_t *ppd,      /* I - PPD file */
     ppd->num_groups ++;
 
     memset(group, 0, sizeof(ppd_group_t));
-    strncpy(group->text, name, sizeof(group->text) - 1);
+    strlcpy(group->text, name, sizeof(group->text));
   }
 
   return (group);
@@ -349,7 +349,7 @@ ppd_get_option(ppd_group_t *group,  /* I - Group */
     group->num_options ++;
 
     memset(option, 0, sizeof(ppd_option_t));
-    strncpy(option->keyword, name, sizeof(option->keyword) - 1);
+    strlcpy(option->keyword, name, sizeof(option->keyword));
   }
 
   return (option);
@@ -381,7 +381,7 @@ ppd_add_choice(ppd_option_t *option,        /* I - Option */
   option->num_choices ++;
 
   memset(choice, 0, sizeof(ppd_choice_t));
-  strncpy(choice->choice, name, sizeof(choice->choice) - 1);
+  strlcpy(choice->choice, name, sizeof(choice->choice));
 
   return (choice);
 }
@@ -411,7 +411,7 @@ ppd_add_size(ppd_file_t *ppd,       /* I - PPD file */
   ppd->num_sizes ++;
 
   memset(size, 0, sizeof(ppd_size_t));
-  strncpy(size->name, name, sizeof(size->name) - 1);
+  strlcpy(size->name, name, sizeof(size->name));
 
   return (size);
 }
@@ -646,8 +646,8 @@ ppdOpen(FILE *fp)           /* I - File to read from */
       ppd->num_profiles ++;
 
       memset(profile, 0, sizeof(ppd_profile_t));
-      strncpy(profile->resolution, name, sizeof(profile->resolution) - 1);
-      strncpy(profile->media_type, text, sizeof(profile->media_type) - 1);
+      strlcpy(profile->resolution, name, sizeof(profile->resolution));
+      strlcpy(profile->media_type, text, sizeof(profile->media_type));
       sscanf(string, "%f%f%f%f%f%f%f%f%f%f%f", &(profile->density),
             &(profile->gamma),
             profile->matrix[0] + 0, profile->matrix[0] + 1,
@@ -751,8 +751,8 @@ ppdOpen(FILE *fp)           /* I - File to read from */
        return (NULL);
       }
 
-      strncpy(choice->text, cupsLangString(language, CUPS_MSG_VARIABLE),
-              sizeof(choice->text) - 1);
+      strlcpy(choice->text, cupsLangString(language, CUPS_MSG_VARIABLE),
+              sizeof(choice->text));
       option = NULL;
     }
     else if (strcmp(keyword, "MaxMediaWidth") == 0)
@@ -821,8 +821,8 @@ ppdOpen(FILE *fp)           /* I - File to read from */
          return (NULL);
        }
 
-       strncpy(choice->text, cupsLangString(language, CUPS_MSG_VARIABLE),
-               sizeof(choice->text) - 1);
+       strlcpy(choice->text, cupsLangString(language, CUPS_MSG_VARIABLE),
+               sizeof(choice->text));
        option = NULL;
       }
 
@@ -994,28 +994,28 @@ ppdOpen(FILE *fp)         /* I - File to read from */
 
       if (text[0])
       {
-        strncpy(option->text, text, sizeof(option->text) - 1);
+        strlcpy(option->text, text, sizeof(option->text));
        ppd_fix(option->text);
       }
       else
       {
         if (strcmp(name, "PageSize") == 0)
-         strncpy(option->text, cupsLangString(language, CUPS_MSG_MEDIA_SIZE),
-                  sizeof(option->text) - 1);
+         strlcpy(option->text, cupsLangString(language, CUPS_MSG_MEDIA_SIZE),
+                  sizeof(option->text));
        else if (strcmp(name, "MediaType") == 0)
-         strncpy(option->text, cupsLangString(language, CUPS_MSG_MEDIA_TYPE),
-                  sizeof(option->text) - 1);
+         strlcpy(option->text, cupsLangString(language, CUPS_MSG_MEDIA_TYPE),
+                  sizeof(option->text));
        else if (strcmp(name, "InputSlot") == 0)
-         strncpy(option->text, cupsLangString(language, CUPS_MSG_MEDIA_SOURCE),
-                  sizeof(option->text) - 1);
+         strlcpy(option->text, cupsLangString(language, CUPS_MSG_MEDIA_SOURCE),
+                  sizeof(option->text));
        else if (strcmp(name, "ColorModel") == 0)
-         strncpy(option->text, cupsLangString(language, CUPS_MSG_OUTPUT_MODE),
-                  sizeof(option->text) - 1);
+         strlcpy(option->text, cupsLangString(language, CUPS_MSG_OUTPUT_MODE),
+                  sizeof(option->text));
        else if (strcmp(name, "Resolution") == 0)
-         strncpy(option->text, cupsLangString(language, CUPS_MSG_RESOLUTION),
-                  sizeof(option->text) - 1);
+         strlcpy(option->text, cupsLangString(language, CUPS_MSG_RESOLUTION),
+                  sizeof(option->text));
         else
-         strncpy(option->text, name, sizeof(option->text) - 1);
+         strlcpy(option->text, name, sizeof(option->text));
       }
 
       option->section = PPD_ORDER_ANY;
@@ -1062,7 +1062,7 @@ ppdOpen(FILE *fp)         /* I - File to read from */
       else
         option->ui = PPD_UI_PICKONE;
 
-      strncpy(option->text, text, sizeof(option->text) - 1);
+      strlcpy(option->text, text, sizeof(option->text));
 
       option->section = PPD_ORDER_JCL;
       group = NULL;
@@ -1192,13 +1192,13 @@ ppdOpen(FILE *fp)               /* I - File to read from */
           for (i = 0; i < temp->num_options; i ++)
            if (strcmp(keyword, temp->options[i].keyword) == 0)
            {
-             strncpy(temp->options[i].defchoice, string,
-                      sizeof(temp->options[i].defchoice) - 1);
+             strlcpy(temp->options[i].defchoice, string,
+                      sizeof(temp->options[i].defchoice));
              break;
            }
       }
       else
-        strncpy(option->defchoice, string, sizeof(option->defchoice) - 1);
+        strlcpy(option->defchoice, string, sizeof(option->defchoice));
     }
     else if (strcmp(keyword, "UIConstraints") == 0 ||
              strcmp(keyword, "NonUIConstraints") == 0)
@@ -1342,7 +1342,7 @@ ppdOpen(FILE *fp)         /* I - File to read from */
 
       if (mask & PPD_TEXT)
       {
-        strncpy(choice->text, text, sizeof(choice->text) - 1);
+        strlcpy(choice->text, text, sizeof(choice->text));
         ppd_fix(choice->text);
       }
       else if (strcmp(name, "True") == 0)
@@ -1350,7 +1350,7 @@ ppdOpen(FILE *fp)         /* I - File to read from */
       else if (strcmp(name, "False") == 0)
         strcpy(choice->text, "No");
       else
-        strncpy(choice->text, name, sizeof(choice->text) - 1);
+        strlcpy(choice->text, name, sizeof(choice->text));
 
       if (option->section == PPD_ORDER_JCL)
         ppd_decode(string);            /* Decode quoted string */
@@ -2028,5 +2028,5 @@ ppd_fix(char *string)             /* IO - String to fix */
 
 
 /*
- * End of "$Id: ppd.c,v 1.67 2002/05/14 16:13:48 mike Exp $".
+ * End of "$Id: ppd.c,v 1.68 2002/05/16 13:44:54 mike Exp $".
  */
index e185fe38e4c2208be62254017468a3f1d2dc1d6d..b7f4ab7de8a823c51e64641007a8876c2c8f162e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: snprintf.c,v 1.6 2002/03/01 19:53:30 mike Exp $"
+ * "$Id: snprintf.c,v 1.7 2002/05/16 13:44:54 mike Exp $"
  *
  *   snprintf functions for the Common UNIX Printing System (CUPS).
  *
@@ -25,8 +25,8 @@
  *
  * Contents:
  *
- *   vsnprintf() - Format a string into a fixed size buffer.
- *   snprintf()  - Format a string into a fixed size buffer.
+ *   cups_vsnprintf() - Format a string into a fixed size buffer.
+ *   cups_snprintf()  - Format a string into a fixed size buffer.
  */
 
 /*
 
 #ifndef HAVE_VSNPRINTF
 /*
- * 'vsnprintf()' - Format a string into a fixed size buffer.
+ * 'cups_vsnprintf()' - Format a string into a fixed size buffer.
  */
 
-int                            /* O - Number of bytes formatted */
-vsnprintf(char       *buffer,  /* O - Output buffer */
-          size_t     bufsize,  /* O - Size of output buffer */
-         const char *format,   /* I - printf-style format string */
-         va_list    ap)        /* I - Pointer to additional arguments */
+int                                    /* O - Number of bytes formatted */
+cups_vsnprintf(char       *buffer,     /* O - Output buffer */
+               size_t     bufsize,     /* O - Size of output buffer */
+              const char *format,      /* I - printf-style format string */
+              va_list    ap)           /* I - Pointer to additional arguments */
 {
-  char         *bufptr,        /* Pointer to position in buffer */
-               *bufend,        /* Pointer to end of buffer */
-               sign,           /* Sign of format width */
-               size,           /* Size character (h, l, L) */
-               type;           /* Format type character */
-  const char   *bufformat;     /* Start of format */
-  int          width,          /* Width of field */
-               prec;           /* Number of characters of precision */
-  char         tformat[100],   /* Temporary format string for sprintf() */
-               temp[1024];     /* Buffer for formatted numbers */
-  int          *chars;         /* Pointer to integer for %p */
-  char         *s;             /* Pointer to string */
-  int          slen;           /* Length of string */
+  char         *bufptr,                /* Pointer to position in buffer */
+               *bufend,                /* Pointer to end of buffer */
+               sign,                   /* Sign of format width */
+               size,                   /* Size character (h, l, L) */
+               type;                   /* Format type character */
+  const char   *bufformat;             /* Start of format */
+  int          width,                  /* Width of field */
+               prec;                   /* Number of characters of precision */
+  char         tformat[100],           /* Temporary format string for sprintf() */
+               temp[1024];             /* Buffer for formatted numbers */
+  int          *chars;                 /* Pointer to integer for %p */
+  char         *s;                     /* Pointer to string */
+  int          slen;                   /* Length of string */
 
 
  /*
@@ -261,17 +261,17 @@ vsnprintf(char       *buffer,     /* O - Output buffer */
 
 #ifndef HAVE_SNPRINTF
 /*
- * 'snprintf()' - Format a string into a fixed size buffer.
+ * 'cups_snprintf()' - Format a string into a fixed size buffer.
  */
 
-int                            /* O - Number of bytes formatted */
-snprintf(char       *buffer,   /* O - Output buffer */
-         size_t     bufsize,   /* O - Size of output buffer */
-         const char *format,   /* I - printf-style format string */
-        ...)                   /* I - Additional arguments as needed */
+int                                    /* O - Number of bytes formatted */
+cups_snprintf(char       *buffer,      /* O - Output buffer */
+              size_t     bufsize,      /* O - Size of output buffer */
+              const char *format,      /* I - printf-style format string */
+             ...)                      /* I - Additional arguments as needed */
 {
-  int          bytes;          /* Number of bytes formatted */
-  va_list      ap;             /* Pointer to additional arguments */
+  int          bytes;                  /* Number of bytes formatted */
+  va_list      ap;                     /* Pointer to additional arguments */
 
 
   va_start(ap, format);
@@ -284,6 +284,6 @@ snprintf(char       *buffer,        /* O - Output buffer */
 
 
 /*
- * End of "$Id: snprintf.c,v 1.6 2002/03/01 19:53:30 mike Exp $".
+ * End of "$Id: snprintf.c,v 1.7 2002/05/16 13:44:54 mike Exp $".
  */
 
index 26e59529632ba79cde447115ddd1048427980830..16d53ba311da57a1749a6b965a0c64e7ed3c08be 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: string.c,v 1.7 2002/03/01 19:53:30 mike Exp $"
+ * "$Id: string.c,v 1.8 2002/05/16 13:44:54 mike Exp $"
  *
  *   String functions for the Common UNIX Printing System (CUPS).
  *
  *
  * Contents:
  *
- *   strdup()      - Duplicate a string.
- *   strcasecmp()  - Do a case-insensitive comparison.
- *   strncasecmp() - Do a case-insensitive comparison on up to N chars.
+ *   cups_strdup()      - Duplicate a string.
+ *   cups_strcasecmp()  - Do a case-insensitive comparison.
+ *   cups_strncasecmp() - Do a case-insensitive comparison on up to N chars.
+ *   cups_strlcat()     - Safely concatenate two strings.
+ *   cups_strlcpy()     - Safely copy two strings.
  */
 
 /*
 
 
 /*
- * 'strdup()' - Duplicate a string.
+ * 'cups_strdup()' - Duplicate a string.
  */
 
-#  ifndef HAVE_STRDUP
-char *                 /* O - New string pointer */
-strdup(const char *s)  /* I - String to duplicate */
+#ifndef HAVE_STRDUP
+char   *                       /* O - New string pointer */
+cups_strdup(const char *s)     /* I - String to duplicate */
 {
-  char *t;             /* New string pointer */
+  char *t;                     /* New string pointer */
 
 
   if (s == NULL)
@@ -56,17 +58,17 @@ strdup(const char *s)       /* I - String to duplicate */
 
   return (strcpy(t, s));
 }
-#  endif /* !HAVE_STRDUP */
+#endif /* !HAVE_STRDUP */
 
 
 /*
- * 'strcasecmp()' - Do a case-insensitive comparison.
+ * 'cups_strcasecmp()' - Do a case-insensitive comparison.
  */
 
-#  ifndef HAVE_STRCASECMP
+#ifndef HAVE_STRCASECMP
 int                            /* O - Result of comparison (-1, 0, or 1) */
-strcasecmp(const char *s,      /* I - First string */
-           const char *t)      /* I - Second string */
+cups_strcasecmp(const char *s, /* I - First string */
+                const char *t) /* I - Second string */
 {
   while (*s != '\0' && *t != '\0')
   {
@@ -86,17 +88,17 @@ strcasecmp(const char *s,   /* I - First string */
   else
     return (-1);
 }
-#  endif /* !HAVE_STRCASECMP */
+#endif /* !HAVE_STRCASECMP */
 
 /*
- * 'strncasecmp()' - Do a case-insensitive comparison on up to N chars.
+ * 'cups_strncasecmp()' - Do a case-insensitive comparison on up to N chars.
  */
 
-#  ifndef HAVE_STRNCASECMP
+#ifndef HAVE_STRNCASECMP
 int                            /* O - Result of comparison (-1, 0, or 1) */
-strncasecmp(const char *s,     /* I - First string */
-            const char *t,     /* I - Second string */
-           size_t     n)       /* I - Maximum number of characters to compare */
+cups_strncasecmp(const char *s,        /* I - First string */
+                 const char *t,        /* I - Second string */
+                size_t     n)  /* I - Maximum number of characters to compare */
 {
   while (*s != '\0' && *t != '\0' && n > 0)
   {
@@ -119,9 +121,90 @@ strncasecmp(const char *s, /* I - First string */
   else
     return (-1);
 }
-#  endif /* !HAVE_STRNCASECMP */
+#endif /* !HAVE_STRNCASECMP */
 
 
+#ifndef HAVE_STRLCAT
 /*
- * End of "$Id: string.c,v 1.7 2002/03/01 19:53:30 mike Exp $".
+ * 'cups_strlcat()' - Safely concatenate two strings.
+ */
+
+size_t                         /* O - Length of string */
+cups_strlcat(char       *dst,  /* O - Destination string */
+             const char *src,  /* I - Source string */
+            size_t     size)   /* I - Size of destination string buffer */
+{
+  size_t       srclen;         /* Length of source string */
+  size_t       dstlen;         /* Length of destination string */
+
+
+ /*
+  * Figure out how much room is left...
+  */
+
+  dstlen = strlen(dst);
+  size   -= dstlen + 1;
+
+  if (!size)
+    return (dstlen);           /* No room, return immediately... */
+
+ /*
+  * Figure out how much room is needed...
+  */
+
+  srclen = strlen(src);
+
+ /*
+  * Copy the appropriate amount...
+  */
+
+  if (srclen > size)
+    srclen = size;
+
+  memcpy(dst + dstlen, src, srclen);
+  dst[dstlen + srclen] = '\0';
+
+  return (dstlen + srclen);
+}
+#endif /* !HAVE_STRLCAT */
+
+
+#ifndef HAVE_STRLCPY
+/*
+ * 'cups_strlcpy()' - Safely copy two strings.
+ */
+
+size_t                         /* O - Length of string */
+cups_strlcpy(char       *dst,  /* O - Destination string */
+             const char *src,  /* I - Source string */
+            size_t      size)  /* I - Size of destination string buffer */
+{
+  size_t       srclen;         /* Length of source string */
+
+
+ /*
+  * Figure out how much room is needed...
+  */
+
+  size --;
+
+  srclen = strlen(src);
+
+ /*
+  * Copy the appropriate amount...
+  */
+
+  if (srclen > size)
+    srclen = size;
+
+  memcpy(dst, src, srclen);
+  dst[srclen] = '\0';
+
+  return (srclen);
+}
+#endif /* !HAVE_STRLCPY */
+
+
+/*
+ * End of "$Id: string.c,v 1.8 2002/05/16 13:44:54 mike Exp $".
  */
index 9a0c9e15121ec0328bd9fb69eafb9616cc730721..db6a8e453bcc43c80bbdd3e7d19e4f68aead0408 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: string.h,v 1.12 2002/05/15 01:52:16 mike Exp $"
+ * "$Id: string.h,v 1.13 2002/05/16 13:44:54 mike Exp $"
  *
  *   String definitions for the Common UNIX Printing System (CUPS).
  *
@@ -70,27 +70,42 @@ extern "C" {
  */
 
 #  ifndef HAVE_STRDUP
-extern char    *strdup(const char *);
+extern char    *cups_strdup(const char *);
+#    define strdup cups_strdup
 #  endif /* !HAVE_STRDUP */
 
 #  ifndef HAVE_STRCASECMP
-extern int     strcasecmp(const char *, const char *);
+extern int     cups_strcasecmp(const char *, const char *);
+#    define strcasecmp cups_strcasecmp
 #  endif /* !HAVE_STRCASECMP */
 
 #  ifndef HAVE_STRNCASECMP
-extern int     strncasecmp(const char *, const char *, size_t n);
+extern int     cups_strncasecmp(const char *, const char *, size_t n);
+#    define strncasecmp cups_strncasecmp
 #  endif /* !HAVE_STRNCASECMP */
 
+#  ifndef HAVE_STRLCAT
+extern size_t cups_strlcat(char *, const char *, size_t);
+#    define strlcat cups_strlcat
+#  endif /* !HAVE_STRLCAT */
+
+#  ifndef HAVE_STRLCPY
+extern size_t cups_strlcpy(char *, const char *, size_t);
+#    define strlcpy cups_strlcpy
+#  endif /* !HAVE_STRLCPY */
+
 #  ifndef HAVE_SNPRINTF
-extern int     snprintf(char *, size_t, const char *, ...)
+extern int     cups_snprintf(char *, size_t, const char *, ...)
 #    ifdef __GNUC__
 __attribute__ ((__format__ (__printf__, 3, 4)))
 #    endif /* __GNUC__ */
 ;
+#    define snprintf cups_snprintf
 #  endif /* !HAVE_SNPRINTF */
 
 #  ifndef HAVE_VSNPRINTF
-extern int     vsnprintf(char *, size_t, const char *, va_list);
+extern int     cups_vsnprintf(char *, size_t, const char *, va_list);
+#    define vsnprintf cups_vsnprintf
 #  endif /* !HAVE_VSNPRINTF */
 
 
@@ -105,5 +120,5 @@ extern int  vsnprintf(char *, size_t, const char *, va_list);
 #endif /* !_CUPS_STRING_H_ */
 
 /*
- * End of "$Id: string.h,v 1.12 2002/05/15 01:52:16 mike Exp $".
+ * End of "$Id: string.h,v 1.13 2002/05/16 13:44:54 mike Exp $".
  */
index b1e80b3e46a665c0d41fd6ea5d58b86aabafc448..264c7ac0fc0b69924e8d73835eb5a6f0b10cfa0d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: usersys.c,v 1.16 2002/03/01 19:53:30 mike Exp $"
+ * "$Id: usersys.c,v 1.17 2002/05/16 13:44:54 mike Exp $"
  *
  *   User, system, and password routines for the Common UNIX Printing
  *   System (CUPS).
@@ -260,8 +260,7 @@ cupsServer(void)
     * Copy the server name over...
     */
 
-    strncpy(cups_server, server, sizeof(cups_server) - 1);
-    cups_server[sizeof(cups_server) - 1] = '\0';
+    strlcpy(cups_server, server, sizeof(cups_server));
   }
 
   return (cups_server);
@@ -290,10 +289,7 @@ void
 cupsSetServer(const char *server)      /* I - Server name */
 {
   if (server)
-  {
-    strncpy(cups_server, server, sizeof(cups_server) - 1);
-    cups_server[sizeof(cups_server) - 1] = '\0';
-  }
+    strlcpy(cups_server, server, sizeof(cups_server));
   else
     cups_server[0] = '\0';
 }
@@ -307,10 +303,7 @@ void
 cupsSetUser(const char *user)          /* I - User name */
 {
   if (user)
-  {
-    strncpy(cups_user, user, sizeof(cups_user) - 1);
-    cups_user[sizeof(cups_user) - 1] = '\0';
-  }
+    strlcpy(cups_user, user, sizeof(cups_user));
   else
     cups_user[0] = '\0';
 }
@@ -383,8 +376,7 @@ cupsUser(void)
 
       setpwent();
 
-      strncpy(cups_user, pwd->pw_name, sizeof(cups_user) - 1);
-      cups_user[sizeof(cups_user) - 1] = '\0';
+      strlcpy(cups_user, pwd->pw_name, sizeof(cups_user));
     }
 
    /*
@@ -445,5 +437,5 @@ cups_get_line(char *buf,    /* I - Line buffer */
 
 
 /*
- * End of "$Id: usersys.c,v 1.16 2002/03/01 19:53:30 mike Exp $".
+ * End of "$Id: usersys.c,v 1.17 2002/05/16 13:44:54 mike Exp $".
  */
index 15ea48d463f41b067db1139fcc6a25368338bba1..6c4eca3c78e2cf2185dccb797fc56e0b23d89499 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: util.c,v 1.93 2002/03/01 19:53:30 mike Exp $"
+ * "$Id: util.c,v 1.94 2002/05/16 13:44:55 mike Exp $"
  *
  *   Printing utilities for the Common UNIX Printing System (CUPS).
  *
@@ -340,8 +340,7 @@ cupsDoFileRequest(http_t     *http, /* I - HTTP connection to server */
        if (!password[0])
          break;
 
-        strncpy(pwdstring, password, sizeof(pwdstring) - 1);
-       pwdstring[sizeof(pwdstring) - 1] = '\0';
+        strlcpy(pwdstring, password, sizeof(pwdstring));
 
         digest_tries = 0;
       }
@@ -683,8 +682,7 @@ cupsGetDefault(void)
 
     if ((attr = ippFindAttribute(response, "printer-name", IPP_TAG_NAME)) != NULL)
     {
-      strncpy(def_printer, attr->values[0].string.text, sizeof(def_printer) - 1);
-      def_printer[sizeof(def_printer) - 1] = '\0';
+      strlcpy(def_printer, attr->values[0].string.text, sizeof(def_printer));
       ippDelete(response);
       return (def_printer);
     }
@@ -1070,8 +1068,7 @@ cupsGetPPD(const char *name)              /* I - Printer name */
          * Found a printer!
          */
 
-         strncpy(printer, resource + 10, sizeof(printer) - 1);
-         printer[sizeof(printer) - 1] = '\0';
+         strlcpy(printer, resource + 10, sizeof(printer));
          break;
        }
       }
@@ -1085,8 +1082,7 @@ cupsGetPPD(const char *name)              /* I - Printer name */
 
       httpSeparate(attr->values[0].string.text, method, username, hostname,
                   &port, resource);
-      strncpy(printer, strrchr(resource, '/') + 1, sizeof(printer) - 1);
-      printer[sizeof(printer) - 1] = '\0';
+      strlcpy(printer, strrchr(resource, '/') + 1, sizeof(printer));
     }
 
     ippDelete(response);
@@ -1204,8 +1200,7 @@ cupsGetPPD(const char *name)              /* I - Printer name */
        if (!password[0])
          break;
 
-        strncpy(pwdstring, password, sizeof(pwdstring) - 1);
-       pwdstring[sizeof(pwdstring) - 1] = '\0';
+        strlcpy(pwdstring, password, sizeof(pwdstring));
 
         digest_tries = 0;
       }
@@ -1635,24 +1630,15 @@ cups_connect(const char *name,          /* I - Destination (printer[@host]) */
   }
 
   if (sscanf(name, "%1023[^@]@%1023s", printerbuf, hostbuf) == 1)
-  {
-    strncpy(hostbuf, cupsServer(), sizeof(hostbuf) - 1);
-    hostbuf[sizeof(hostbuf) - 1] = '\0';
-  }
+    strlcpy(hostbuf, cupsServer(), sizeof(hostbuf));
 
   if (hostname != NULL)
-  {
-    strncpy(hostname, hostbuf, HTTP_MAX_URI - 1);
-    hostname[HTTP_MAX_URI - 1] = '\0';
-  }
+    strlcpy(hostname, hostbuf, HTTP_MAX_URI);
   else
     hostname = hostbuf;
 
   if (printer != NULL)
-  {
-    strncpy(printer, printerbuf, HTTP_MAX_URI - 1);
-    printer[HTTP_MAX_URI - 1] = '\0';
-  }
+    strlcpy(printer, printerbuf, HTTP_MAX_URI);
   else
     printer = printerbuf;
 
@@ -1745,5 +1731,5 @@ cups_local_auth(http_t *http)     /* I - Connection */
 
 
 /*
- * End of "$Id: util.c,v 1.93 2002/03/01 19:53:30 mike Exp $".
+ * End of "$Id: util.c,v 1.94 2002/05/16 13:44:55 mike Exp $".
  */
index f646f5ea7078582c533e4891a72ab9b96762f7d9..fcc94363b18c513e18c518fc51015ac46d062111 100644 (file)
@@ -24,21 +24,21 @@ hpgl-polygon.o: ../cups/string.h ../config.h
 hpgl-vector.o: hpgltops.h common.h ../cups/cups.h ../cups/ipp.h
 hpgl-vector.o: ../cups/http.h ../cups/md5.h ../cups/ppd.h ../cups/language.h
 hpgl-vector.o: ../cups/string.h ../config.h
-image-bmp.o: image.h ../config.h
-image-colorspace.o: image.h ../config.h
-image-gif.o: image.h ../config.h
-image-jpeg.o: image.h ../config.h
-image-photocd.o: image.h ../config.h
-image-pix.o: image.h ../config.h
-image-png.o: image.h ../config.h
-image-pnm.o: image.h ../config.h
-image-sgi.o: image.h ../config.h image-sgi.h
+image-bmp.o: image.h ../config.h raster.h
+image-colorspace.o: image.h ../config.h raster.h
+image-gif.o: image.h ../config.h raster.h
+image-jpeg.o: image.h ../config.h raster.h
+image-photocd.o: image.h ../config.h raster.h
+image-pix.o: image.h ../config.h raster.h
+image-png.o: image.h ../config.h raster.h
+image-pnm.o: image.h ../config.h raster.h
+image-sgi.o: image.h ../config.h raster.h image-sgi.h
 image-sgilib.o: image-sgi.h
-image-sun.o: image.h ../config.h
-image-tiff.o: image.h ../config.h
-image-zoom.o: image.h ../config.h
-image.o: image.h ../config.h ../cups/cups.h ../cups/ipp.h ../cups/http.h
-image.o: ../cups/md5.h ../cups/ppd.h
+image-sun.o: image.h ../config.h raster.h
+image-tiff.o: image.h ../config.h raster.h
+image-zoom.o: image.h ../config.h raster.h
+image.o: image.h ../config.h raster.h ../cups/cups.h ../cups/ipp.h
+image.o: ../cups/http.h ../cups/md5.h ../cups/ppd.h
 raster.o: raster.h
 form-main.o: form.h common.h ../cups/cups.h ../cups/ipp.h ../cups/http.h
 form-main.o: ../cups/md5.h ../cups/ppd.h ../cups/language.h ../cups/string.h
@@ -51,7 +51,7 @@ form-tree.o: ../cups/md5.h ../cups/ppd.h ../cups/language.h ../cups/string.h
 form-tree.o: ../config.h
 imagetops.o: common.h ../cups/cups.h ../cups/ipp.h ../cups/http.h
 imagetops.o: ../cups/md5.h ../cups/ppd.h ../cups/language.h ../cups/string.h
-imagetops.o: ../config.h image.h
+imagetops.o: ../config.h image.h raster.h
 imagetoraster.o: common.h ../cups/cups.h ../cups/ipp.h ../cups/http.h
 imagetoraster.o: ../cups/md5.h ../cups/ppd.h ../cups/language.h
 imagetoraster.o: ../cups/string.h ../config.h image.h raster.h
index f82f86abe6c2ccdaf9b8e036af37b19d3ae85ee9..e02a892010f529e6c0cf71e3608c12a0c89f48f4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: imagetops.c,v 1.45 2002/04/19 16:17:28 mike Exp $"
+ * "$Id: imagetops.c,v 1.46 2002/05/16 13:44:55 mike Exp $"
  *
  *   Image file to PostScript filter for the Common UNIX Printing System (CUPS).
  *
@@ -152,10 +152,7 @@ main(int  argc,            /* I - Number of command-line arguments */
     close(fd);
   }
   else
-  {
-    strncpy(filename, argv[6], sizeof(filename) - 1);
-    filename[sizeof(filename) - 1] = '\0';
-  }
+    strlcpy(filename, argv[6], sizeof(filename));
 
  /*
   * Process command-line options and write the prolog...
@@ -885,5 +882,5 @@ ps_ascii85(ib_t *data,              /* I - Data to print */
 
 
 /*
- * End of "$Id: imagetops.c,v 1.45 2002/04/19 16:17:28 mike Exp $".
+ * End of "$Id: imagetops.c,v 1.46 2002/05/16 13:44:55 mike Exp $".
  */
index 7e63e7a0a0e978ec2af31a1fcd542b6262fb58f6..9984f027cbc721a786a10afa4db7246138ff594b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: imagetoraster.c,v 1.64 2002/04/29 15:56:59 mike Exp $"
+ * "$Id: imagetoraster.c,v 1.65 2002/05/16 13:44:56 mike Exp $"
  *
  *   Image file to raster filter for the Common UNIX Printing System (CUPS).
  *
@@ -369,10 +369,7 @@ main(int  argc,            /* I - Number of command-line arguments */
     close(fd);
   }
   else
-  {
-    strncpy(filename, argv[6], sizeof(filename) - 1);
-    filename[sizeof(filename) - 1] = '\0';
-  }
+    strlcpy(filename, argv[6], sizeof(filename));
 
  /*
   * Process command-line options and write the prolog...
@@ -1528,13 +1525,13 @@ exec_code(cups_page_header_t *header,   /* I - Page header */
              strcmp(name, "MediaPosition") == 0)
       header->MediaPosition = atoi(value);
     else if (strcmp(name, "MediaClass") == 0)
-      strncpy(header->MediaClass, value, sizeof(header->MediaClass) - 1);
+      strlcpy(header->MediaClass, value, sizeof(header->MediaClass));
     else if (strcmp(name, "MediaColor") == 0)
-      strncpy(header->MediaColor, value, sizeof(header->MediaColor) - 1);
+      strlcpy(header->MediaColor, value, sizeof(header->MediaColor));
     else if (strcmp(name, "MediaType") == 0)
-      strncpy(header->MediaType, value, sizeof(header->MediaType) - 1);
+      strlcpy(header->MediaType, value, sizeof(header->MediaType));
     else if (strcmp(name, "OutputType") == 0)
-      strncpy(header->OutputType, value, sizeof(header->OutputType) - 1);
+      strlcpy(header->OutputType, value, sizeof(header->OutputType));
   }
 }
 
@@ -4506,5 +4503,5 @@ make_lut(ib_t  *lut,              /* I - Lookup table */
 
 
 /*
- * End of "$Id: imagetoraster.c,v 1.64 2002/04/29 15:56:59 mike Exp $".
+ * End of "$Id: imagetoraster.c,v 1.65 2002/05/16 13:44:56 mike Exp $".
  */
index 69569a2b24b0a1717bfd3787355fc09565b537f7..07af19f1a657f63e59e3e571e735337d24fdeee0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: gdevcups.c,v 1.51 2002/04/23 17:28:59 mike Exp $"
+ * "$Id: gdevcups.c,v 1.52 2002/05/16 13:44:57 mike Exp $"
  *
  *   GNU Ghostscript raster output driver for the Common UNIX Printing
  *   System (CUPS).
@@ -1808,9 +1808,7 @@ cups_put_params(gx_device     *pdev,      /* I - Device info */
   } \
   else if (code == 0) \
   { \
-    strncpy(cups->header.name, (const char *)stringval.data, \
-            stringval.size); \
-    cups->header.name[stringval.size] = '\0'; \
+    strlcpy(cups->header.name, (const char *)stringval.data, 64); \
   }
 
 #define intoption(name, sname, type) \
@@ -3427,5 +3425,5 @@ cups_print_planar(gx_device_printer *pdev,        /* I - Printer device */
 
 
 /*
- * End of "$Id: gdevcups.c,v 1.51 2002/04/23 17:28:59 mike Exp $".
+ * End of "$Id: gdevcups.c,v 1.52 2002/05/16 13:44:57 mike Exp $".
  */
index d98c592e35ff25ad5e3f87c91906a0cff69a6f23..7e688d60f517c9ac88abfe59eec1f74a13c297de 100644 (file)
@@ -1,95 +1,95 @@
 # DO NOT DELETE
 
 auth.o: cupsd.h ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/md5.h
-auth.o: ../cups/ppd.h ../cups/string.h ../config.h mime.h ../cups/http.h
-auth.o: ../cups/ipp.h ../cups/language.h ../cups/debug.h cert.h client.h
+auth.o: ../cups/ppd.h ../cups/string.h ../config.h mime.h ../cups/ipp.h
+auth.o: ../cups/http.h ../cups/language.h ../cups/debug.h cert.h client.h
 auth.o: auth.h printers.h classes.h job.h conf.h banners.h dirsvc.h network.h
 auth.o: ../cups/md5.h
 banners.o: cupsd.h ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/md5.h
-banners.o: ../cups/ppd.h ../cups/string.h ../config.h mime.h ../cups/http.h
-banners.o: ../cups/ipp.h ../cups/language.h ../cups/debug.h cert.h client.h
+banners.o: ../cups/ppd.h ../cups/string.h ../config.h mime.h ../cups/ipp.h
+banners.o: ../cups/http.h ../cups/language.h ../cups/debug.h cert.h client.h
 banners.o: auth.h printers.h classes.h job.h conf.h banners.h dirsvc.h
 banners.o: network.h
 cert.o: cupsd.h ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/md5.h
-cert.o: ../cups/ppd.h ../cups/string.h ../config.h mime.h ../cups/http.h
-cert.o: ../cups/ipp.h ../cups/language.h ../cups/debug.h cert.h client.h
+cert.o: ../cups/ppd.h ../cups/string.h ../config.h mime.h ../cups/ipp.h
+cert.o: ../cups/http.h ../cups/language.h ../cups/debug.h cert.h client.h
 cert.o: auth.h printers.h classes.h job.h conf.h banners.h dirsvc.h network.h
 classes.o: cupsd.h ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/md5.h
-classes.o: ../cups/ppd.h ../cups/string.h ../config.h mime.h ../cups/http.h
-classes.o: ../cups/ipp.h ../cups/language.h ../cups/debug.h cert.h client.h
+classes.o: ../cups/ppd.h ../cups/string.h ../config.h mime.h ../cups/ipp.h
+classes.o: ../cups/http.h ../cups/language.h ../cups/debug.h cert.h client.h
 classes.o: auth.h printers.h classes.h job.h conf.h banners.h dirsvc.h
 classes.o: network.h
 client.o: cupsd.h ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/md5.h
-client.o: ../cups/ppd.h ../cups/string.h ../config.h mime.h ../cups/http.h
-client.o: ../cups/ipp.h ../cups/language.h ../cups/debug.h cert.h client.h
+client.o: ../cups/ppd.h ../cups/string.h ../config.h mime.h ../cups/ipp.h
+client.o: ../cups/http.h ../cups/language.h ../cups/debug.h cert.h client.h
 client.o: auth.h printers.h classes.h job.h conf.h banners.h dirsvc.h
 client.o: network.h
 conf.o: cupsd.h ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/md5.h
-conf.o: ../cups/ppd.h ../cups/string.h ../config.h mime.h ../cups/http.h
-conf.o: ../cups/ipp.h ../cups/language.h ../cups/debug.h cert.h client.h
+conf.o: ../cups/ppd.h ../cups/string.h ../config.h mime.h ../cups/ipp.h
+conf.o: ../cups/http.h ../cups/language.h ../cups/debug.h cert.h client.h
 conf.o: auth.h printers.h classes.h job.h conf.h banners.h dirsvc.h network.h
 devices.o: cupsd.h ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/md5.h
-devices.o: ../cups/ppd.h ../cups/string.h ../config.h mime.h ../cups/http.h
-devices.o: ../cups/ipp.h ../cups/language.h ../cups/debug.h cert.h client.h
+devices.o: ../cups/ppd.h ../cups/string.h ../config.h mime.h ../cups/ipp.h
+devices.o: ../cups/http.h ../cups/language.h ../cups/debug.h cert.h client.h
 devices.o: auth.h printers.h classes.h job.h conf.h banners.h dirsvc.h
 devices.o: network.h
 dirsvc.o: cupsd.h ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/md5.h
-dirsvc.o: ../cups/ppd.h ../cups/string.h ../config.h mime.h ../cups/http.h
-dirsvc.o: ../cups/ipp.h ../cups/language.h ../cups/debug.h cert.h client.h
+dirsvc.o: ../cups/ppd.h ../cups/string.h ../config.h mime.h ../cups/ipp.h
+dirsvc.o: ../cups/http.h ../cups/language.h ../cups/debug.h cert.h client.h
 dirsvc.o: auth.h printers.h classes.h job.h conf.h banners.h dirsvc.h
 dirsvc.o: network.h
 main.o: cupsd.h ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/md5.h
-main.o: ../cups/ppd.h ../cups/string.h ../config.h mime.h ../cups/http.h
-main.o: ../cups/ipp.h ../cups/language.h ../cups/debug.h cert.h client.h
+main.o: ../cups/ppd.h ../cups/string.h ../config.h mime.h ../cups/ipp.h
+main.o: ../cups/http.h ../cups/language.h ../cups/debug.h cert.h client.h
 main.o: auth.h printers.h classes.h job.h conf.h banners.h dirsvc.h network.h
 ipp.o: cupsd.h ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/md5.h
-ipp.o: ../cups/ppd.h ../cups/string.h ../config.h mime.h ../cups/http.h
-ipp.o: ../cups/ipp.h ../cups/language.h ../cups/debug.h cert.h client.h
+ipp.o: ../cups/ppd.h ../cups/string.h ../config.h mime.h ../cups/ipp.h
+ipp.o: ../cups/http.h ../cups/language.h ../cups/debug.h cert.h client.h
 ipp.o: auth.h printers.h classes.h job.h conf.h banners.h dirsvc.h network.h
 listen.o: cupsd.h ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/md5.h
-listen.o: ../cups/ppd.h ../cups/string.h ../config.h mime.h ../cups/http.h
-listen.o: ../cups/ipp.h ../cups/language.h ../cups/debug.h cert.h client.h
+listen.o: ../cups/ppd.h ../cups/string.h ../config.h mime.h ../cups/ipp.h
+listen.o: ../cups/http.h ../cups/language.h ../cups/debug.h cert.h client.h
 listen.o: auth.h printers.h classes.h job.h conf.h banners.h dirsvc.h
 listen.o: network.h
 job.o: cupsd.h ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/md5.h
-job.o: ../cups/ppd.h ../cups/string.h ../config.h mime.h ../cups/http.h
-job.o: ../cups/ipp.h ../cups/language.h ../cups/debug.h cert.h client.h
+job.o: ../cups/ppd.h ../cups/string.h ../config.h mime.h ../cups/ipp.h
+job.o: ../cups/http.h ../cups/language.h ../cups/debug.h cert.h client.h
 job.o: auth.h printers.h classes.h job.h conf.h banners.h dirsvc.h network.h
 log.o: cupsd.h ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/md5.h
-log.o: ../cups/ppd.h ../cups/string.h ../config.h mime.h ../cups/http.h
-log.o: ../cups/ipp.h ../cups/language.h ../cups/debug.h cert.h client.h
+log.o: ../cups/ppd.h ../cups/string.h ../config.h mime.h ../cups/ipp.h
+log.o: ../cups/http.h ../cups/language.h ../cups/debug.h cert.h client.h
 log.o: auth.h printers.h classes.h job.h conf.h banners.h dirsvc.h network.h
 network.o: cupsd.h ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/md5.h
-network.o: ../cups/ppd.h ../cups/string.h ../config.h mime.h ../cups/http.h
-network.o: ../cups/ipp.h ../cups/language.h ../cups/debug.h cert.h client.h
+network.o: ../cups/ppd.h ../cups/string.h ../config.h mime.h ../cups/ipp.h
+network.o: ../cups/http.h ../cups/language.h ../cups/debug.h cert.h client.h
 network.o: auth.h printers.h classes.h job.h conf.h banners.h dirsvc.h
 network.o: network.h
 ppds.o: cupsd.h ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/md5.h
-ppds.o: ../cups/ppd.h ../cups/string.h ../config.h mime.h ../cups/http.h
-ppds.o: ../cups/ipp.h ../cups/language.h ../cups/debug.h cert.h client.h
+ppds.o: ../cups/ppd.h ../cups/string.h ../config.h mime.h ../cups/ipp.h
+ppds.o: ../cups/http.h ../cups/language.h ../cups/debug.h cert.h client.h
 ppds.o: auth.h printers.h classes.h job.h conf.h banners.h dirsvc.h network.h
 printers.o: cupsd.h ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/md5.h
-printers.o: ../cups/ppd.h ../cups/string.h ../config.h mime.h ../cups/http.h
-printers.o: ../cups/ipp.h ../cups/language.h ../cups/debug.h cert.h client.h
+printers.o: ../cups/ppd.h ../cups/string.h ../config.h mime.h ../cups/ipp.h
+printers.o: ../cups/http.h ../cups/language.h ../cups/debug.h cert.h client.h
 printers.o: auth.h printers.h classes.h job.h conf.h banners.h dirsvc.h
 printers.o: network.h
 quotas.o: cupsd.h ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/md5.h
-quotas.o: ../cups/ppd.h ../cups/string.h ../config.h mime.h ../cups/http.h
-quotas.o: ../cups/ipp.h ../cups/language.h ../cups/debug.h cert.h client.h
+quotas.o: ../cups/ppd.h ../cups/string.h ../config.h mime.h ../cups/ipp.h
+quotas.o: ../cups/http.h ../cups/language.h ../cups/debug.h cert.h client.h
 quotas.o: auth.h printers.h classes.h job.h conf.h banners.h dirsvc.h
 quotas.o: network.h
 server.o: cupsd.h ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/md5.h
-server.o: ../cups/ppd.h ../cups/string.h ../config.h mime.h ../cups/http.h
-server.o: ../cups/ipp.h ../cups/language.h ../cups/debug.h cert.h client.h
+server.o: ../cups/ppd.h ../cups/string.h ../config.h mime.h ../cups/ipp.h
+server.o: ../cups/http.h ../cups/language.h ../cups/debug.h cert.h client.h
 server.o: auth.h printers.h classes.h job.h conf.h banners.h dirsvc.h
 server.o: network.h
-filter.o: ../cups/string.h ../config.h mime.h
-mime.o: ../cups/string.h ../config.h mime.h
-type.o: ../cups/string.h ../config.h mime.h ../cups/debug.h
+filter.o: ../cups/string.h ../config.h mime.h ../cups/ipp.h
+mime.o: ../cups/string.h ../config.h mime.h ../cups/ipp.h
+type.o: ../cups/string.h ../config.h mime.h ../cups/ipp.h ../cups/debug.h
 cups-lpd.o: ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/md5.h
 cups-lpd.o: ../cups/ppd.h ../cups/string.h ../config.h ../cups/language.h
 cups-polld.o: ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/md5.h
 cups-polld.o: ../cups/ppd.h ../cups/language.h ../cups/string.h ../config.h
-testmime.o: mime.h
+testmime.o: ../cups/string.h ../config.h mime.h ../cups/ipp.h
 testspeed.o: ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/md5.h
 testspeed.o: ../cups/ppd.h ../cups/language.h ../cups/debug.h
index 280414f8c762afba8a685b347d45a65d9b0f0245..98876505c7f30f0025de86ca1d502e77a4922986 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: auth.c,v 1.57 2002/03/27 19:59:49 mike Exp $"
+ * "$Id: auth.c,v 1.58 2002/05/16 13:44:58 mike Exp $"
  *
  *   Authorization routines for the Common UNIX Printing System (CUPS).
  *
@@ -130,7 +130,7 @@ AddLocation(const char *location)   /* I - Location path */
   */
 
   memset(temp, 0, sizeof(location_t));
-  strncpy(temp->location, location, sizeof(temp->location) - 1);
+  strlcpy(temp->location, location, sizeof(temp->location));
   temp->length = strlen(temp->location);
 
   LogMessage(L_DEBUG, "AddLocation: added location \'%s\'", location);
@@ -211,8 +211,7 @@ AllowHost(location_t *loc,  /* I - Location to add to */
     * Allow *interface*...
     */
 
-    strncpy(ifname, name + 4, sizeof(ifname) - 1);
-    ifname[sizeof(ifname) - 1] = '\0';
+    strlcpy(ifname, name + 4, sizeof(ifname));
 
     ifptr = ifname + strlen(ifname);
 
@@ -587,8 +586,7 @@ DenyHost(location_t *loc,   /* I - Location to add to */
     * Deny *interface*...
     */
 
-    strncpy(ifname, name + 4, sizeof(ifname) - 1);
-    ifname[sizeof(ifname) - 1] = '\0';
+    strlcpy(ifname, name + 4, sizeof(ifname));
 
     ifptr = ifname + strlen(ifname);
 
@@ -683,8 +681,7 @@ FindBest(const char   *path,        /* I - Resource path */
   * URIs...
   */
 
-  strncpy(uri, path, sizeof(uri) - 1);
-  uri[sizeof(uri) - 1] = '\0';
+  strlcpy(uri, path, sizeof(uri));
 
   if (strncmp(uri, "/printers/", 10) == 0 ||
       strncmp(uri, "/classes/", 9) == 0)
@@ -1624,5 +1621,5 @@ to64(char          *s,    /* O - Output string */
 
 
 /*
- * End of "$Id: auth.c,v 1.57 2002/03/27 19:59:49 mike Exp $".
+ * End of "$Id: auth.c,v 1.58 2002/05/16 13:44:58 mike Exp $".
  */
index 9548eec9a5270f439b51d1a9a18b8ca3dabba0f2..90d7e67a33bbee654d6778036dbd5ab02792cfdf 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: banners.c,v 1.7 2002/01/02 17:59:13 mike Exp $"
+ * "$Id: banners.c,v 1.8 2002/05/16 13:44:58 mike Exp $"
  *
  *   Banner routines for the Common UNIX Printing System (CUPS).
  *
@@ -90,7 +90,7 @@ AddBanner(const char *name,   /* I - Name of banner */
   NumBanners ++;
 
   memset(temp, 0, sizeof(banner_t));
-  strncpy(temp->name, name, sizeof(temp->name) - 1);
+  strlcpy(temp->name, name, sizeof(temp->name));
   temp->filetype = filetype;
 }
 
@@ -105,8 +105,7 @@ FindBanner(const char *name)        /* I - Name of banner */
   banner_t     key;            /* Search key */
 
 
-  strncpy(key.name, name, sizeof(key.name) - 1);
-  key.name[sizeof(key.name) - 1] = '\0';
+  strlcpy(key.name, name, sizeof(key.name));
 
   return ((banner_t *)bsearch(&key, Banners, NumBanners, sizeof(banner_t),
                               (int (*)(const void *, const void *))compare));
@@ -212,5 +211,5 @@ compare(const banner_t *b0, /* I - First banner */
 
 
 /*
- * End of "$Id: banners.c,v 1.7 2002/01/02 17:59:13 mike Exp $".
+ * End of "$Id: banners.c,v 1.8 2002/05/16 13:44:58 mike Exp $".
  */
index 43424f446fc781ad96a60e24ecc4241b06c1152e..aea440b35e490e865e9e9760eca8e6df45e535da 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: cert.c,v 1.10 2002/01/02 17:59:13 mike Exp $"
+ * "$Id: cert.c,v 1.11 2002/05/16 13:44:58 mike Exp $"
  *
  *   Authentication certificate routines for the Common UNIX
  *   Printing System (CUPS).
@@ -69,7 +69,7 @@ AddCert(int        pid,                       /* I - Process ID */
   */
 
   cert->pid = pid;
-  strncpy(cert->username, username, sizeof(cert->username) - 1);
+  strlcpy(cert->username, username, sizeof(cert->username));
 
   for (i = 0; i < 32; i ++)
     cert->certificate[i] = hex[random() & 15];
@@ -271,5 +271,5 @@ InitCerts(void)
 
 
 /*
- * End of "$Id: cert.c,v 1.10 2002/01/02 17:59:13 mike Exp $".
+ * End of "$Id: cert.c,v 1.11 2002/05/16 13:44:58 mike Exp $".
  */
index f0c27efd65652416c7e4cdbe0c55da184d3873c2..c1150820b1d726b1382e737ba0a2456cdd951dc6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: classes.c,v 1.41 2002/01/02 17:59:14 mike Exp $"
+ * "$Id: classes.c,v 1.42 2002/05/16 13:44:58 mike Exp $"
  *
  *   Printer class routines for the Common UNIX Printing System (CUPS).
  *
@@ -450,9 +450,9 @@ LoadAllClasses(void)
     }
     
     else if (strcmp(name, "Info") == 0)
-      strncpy(p->info, value, sizeof(p->info) - 1);
+      strlcpy(p->info, value, sizeof(p->info));
     else if (strcmp(name, "Location") == 0)
-      strncpy(p->location, value, sizeof(p->location) - 1);
+      strlcpy(p->location, value, sizeof(p->location));
     else if (strcmp(name, "Printer") == 0)
     {
       if ((temp = FindPrinter(value)) == NULL)
@@ -501,7 +501,7 @@ LoadAllClasses(void)
       while (isspace(*value))
         value ++;
 
-      strncpy(p->state_message, value, sizeof(p->state_message) - 1);
+      strlcpy(p->state_message, value, sizeof(p->state_message));
     }
     else if (strcmp(name, "Accepting") == 0)
     {
@@ -525,7 +525,7 @@ LoadAllClasses(void)
       if (*valueptr)
         *valueptr++ = '\0';
 
-      strncpy(p->job_sheets[0], value, sizeof(p->job_sheets[0]) - 1);
+      strlcpy(p->job_sheets[0], value, sizeof(p->job_sheets[0]));
 
       while (isspace(*valueptr))
         valueptr ++;
@@ -537,7 +537,7 @@ LoadAllClasses(void)
        if (*valueptr)
           *valueptr++ = '\0';
 
-       strncpy(p->job_sheets[1], value, sizeof(p->job_sheets[1]) - 1);
+       strlcpy(p->job_sheets[1], value, sizeof(p->job_sheets[1]));
       }
     }
     else if (strcmp(name, "AllowUser") == 0)
@@ -691,5 +691,5 @@ SaveAllClasses(void)
 
 
 /*
- * End of "$Id: classes.c,v 1.41 2002/01/02 17:59:14 mike Exp $".
+ * End of "$Id: classes.c,v 1.42 2002/05/16 13:44:58 mike Exp $".
  */
index 3be1f2dfd59ecdbd34001cd22a23ab3dcf715ab7..229f6b1da2baa1eea5ee4f1b536f4c98c81462bc 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: client.c,v 1.111 2002/05/15 01:52:17 mike Exp $"
+ * "$Id: client.c,v 1.112 2002/05/16 13:44:59 mike Exp $"
  *
  *   Client routines for the Common UNIX Printing System (CUPS) scheduler.
  *
@@ -140,7 +140,7 @@ AcceptClient(listener_t *lis)       /* I - Listener socket */
     * Map accesses from the same host to the server name.
     */
 
-    strncpy(con->http.hostname, ServerName, sizeof(con->http.hostname) - 1);
+    strlcpy(con->http.hostname, ServerName, sizeof(con->http.hostname));
   }
   else if (host == NULL)
   {
@@ -165,7 +165,7 @@ AcceptClient(listener_t *lis)       /* I - Listener socket */
     }
   }
   else
-    strncpy(con->http.hostname, host->h_name, sizeof(con->http.hostname) - 1);
+    strlcpy(con->http.hostname, host->h_name, sizeof(con->http.hostname));
 
   if (HostNameLookups == 2)
   {
@@ -1949,11 +1949,8 @@ decode_auth(client_t *con)               /* I - Client to decode to */
 
     *s++ = '\0';
 
-    strncpy(con->username, value, sizeof(con->username) - 1);
-    con->username[sizeof(con->username) - 1] = '\0';
-
-    strncpy(con->password, s, sizeof(con->password) - 1);
-    con->password[sizeof(con->password) - 1] = '\0';
+    strlcpy(con->username, value, sizeof(con->username));
+    strlcpy(con->password, s, sizeof(con->password));
   }
   else if (strncmp(s, "Local", 5) == 0)
   {
@@ -1962,10 +1959,7 @@ decode_auth(client_t *con)               /* I - Client to decode to */
       s ++;
 
     if ((username = FindCert(s)) != NULL)
-    {
-      strncpy(con->username, username, sizeof(con->username) - 1);
-      con->username[sizeof(con->username) - 1] = '\0';
-    }
+      strlcpy(con->username, username, sizeof(con->username));
   }
   else if (strncmp(s, "Digest", 5) == 0)
   {
@@ -1975,17 +1969,11 @@ decode_auth(client_t *con)              /* I - Client to decode to */
 
     if (httpGetSubField(&(con->http), HTTP_FIELD_AUTHORIZATION, "username",
                         value))
-    {
-      strncpy(con->username, value, sizeof(con->username) - 1);
-      con->username[sizeof(con->username) - 1] = '\0';
-    }
+      strlcpy(con->username, value, sizeof(con->username));
 
     if (httpGetSubField(&(con->http), HTTP_FIELD_AUTHORIZATION, "response",
                         value))
-    {
-      strncpy(con->password, value, sizeof(con->password) - 1);
-      con->password[sizeof(con->password) - 1] = '\0';
-    }
+      strlcpy(con->password, value, sizeof(con->password));
   }
 
   LogMessage(L_DEBUG2, "decode_auth() %d username=\"%s\"",
@@ -2050,11 +2038,9 @@ get_file(client_t    *con,       /* I - Client connection */
   if (!status && S_ISDIR(filestats->st_mode))
   {
     if (filename[strlen(filename) - 1] == '/')
-      strncat(filename, "index.html", sizeof(filename));
+      strlcat(filename, "index.html", sizeof(filename));
     else
-      strncat(filename, "/index.html", sizeof(filename));
-
-    filename[sizeof(filename) - 1] = '\0';
+      strlcat(filename, "/index.html", sizeof(filename));
 
     status = stat(filename, filestats);
   }
@@ -2263,8 +2249,7 @@ pipe_command(client_t *con,       /* I - Client connection */
   * Copy the command string...
   */
 
-  strncpy(argbuf, options, sizeof(argbuf) - 1);
-  argbuf[sizeof(argbuf) - 1] = '\0';
+  strlcpy(argbuf, options, sizeof(argbuf));
 
  /*
   * Parse the string; arguments can be separated by + and are terminated
@@ -2510,5 +2495,5 @@ pipe_command(client_t *con,       /* I - Client connection */
 
 
 /*
- * End of "$Id: client.c,v 1.111 2002/05/15 01:52:17 mike Exp $".
+ * End of "$Id: client.c,v 1.112 2002/05/16 13:44:59 mike Exp $".
  */
index 57dd0224eb414fbc13755b83f7f04298ba987a10..ffd0f73a2c102160598c30122bb31f654898b8b5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: conf.c,v 1.102 2002/05/15 01:52:17 mike Exp $"
+ * "$Id: conf.c,v 1.103 2002/05/16 13:44:59 mike Exp $"
  *
  *   Configuration routines for the Common UNIX Printing System (CUPS).
  *
@@ -246,8 +246,7 @@ ReadConfiguration(void)
   else if (strcmp(language, "C") == 0 || strcmp(language, "POSIX") == 0)
     language = "en";
 
-  strncpy(DefaultLanguage, language, sizeof(DefaultLanguage) - 1);
-  DefaultLanguage[sizeof(DefaultLanguage) - 1] = '\0';
+  strlcpy(DefaultLanguage, language, sizeof(DefaultLanguage));
 
   strcpy(DefaultCharset, DEFAULT_CHARSET);
 
@@ -256,10 +255,7 @@ ReadConfiguration(void)
   if (getenv("TMPDIR") == NULL)
     strcpy(TempDir, CUPS_REQUESTS "/tmp");
   else
-  {
-    strncpy(TempDir, getenv("TMPDIR"), sizeof(TempDir) - 1);
-    TempDir[sizeof(TempDir) - 1] = '\0';
-  }
+    strlcpy(TempDir, getenv("TMPDIR"), sizeof(TempDir));
 
  /*
   * Find the default system group: "sys", "system", or "root"...
@@ -396,30 +392,26 @@ ReadConfiguration(void)
   if (DocumentRoot[0] != '/')
   {
     snprintf(directory, sizeof(directory), "%s/%s", ServerRoot, DocumentRoot);
-    strncpy(DocumentRoot, directory, sizeof(DocumentRoot) - 1);
-    DocumentRoot[sizeof(DocumentRoot) - 1] = '\0';
+    strlcpy(DocumentRoot, directory, sizeof(DocumentRoot));
   }
 
   if (RequestRoot[0] != '/')
   {
     snprintf(directory, sizeof(directory), "%s/%s", ServerRoot, RequestRoot);
-    strncpy(RequestRoot, directory, sizeof(RequestRoot) - 1);
-    RequestRoot[sizeof(RequestRoot) - 1] = '\0';
+    strlcpy(RequestRoot, directory, sizeof(RequestRoot));
   }
 
   if (ServerBin[0] != '/')
   {
     snprintf(directory, sizeof(directory), "%s/%s", ServerRoot, ServerBin);
-    strncpy(ServerBin, directory, sizeof(ServerBin) - 1);
-    ServerBin[sizeof(ServerBin) - 1] = '\0';
+    strlcpy(ServerBin, directory, sizeof(ServerBin));
   }
 
 #ifdef HAVE_LIBSSL
   if (ServerCertificate[0] != '/')
   {
     snprintf(directory, sizeof(directory), "%s/%s", ServerRoot, ServerCertificate);
-    strncpy(ServerCertificate, directory, sizeof(ServerCertificate) - 1);
-    ServerCertificate[sizeof(ServerCertificate) - 1] = '\0';
+    strlcpy(ServerCertificate, directory, sizeof(ServerCertificate));
   }
 
   chown(ServerCertificate, User, Group);
@@ -428,8 +420,7 @@ ReadConfiguration(void)
   if (ServerKey[0] != '/')
   {
     snprintf(directory, sizeof(directory), "%s/%s", ServerRoot, ServerKey);
-    strncpy(ServerKey, directory, sizeof(ServerKey) - 1);
-    ServerKey[sizeof(ServerKey) - 1] = '\0';
+    strlcpy(ServerKey, directory, sizeof(ServerKey));
   }
 
   chown(ServerKey, User, Group);
@@ -679,10 +670,7 @@ read_configuration(FILE *fp)               /* I - File to read from */
       */
 
       if (value[0] == '/')
-      {
-        strncpy(incname, value, sizeof(incname) - 1);
-       incname[sizeof(incname) - 1] = '\0';
-      }
+        strlcpy(incname, value, sizeof(incname));
       else
         snprintf(incname, sizeof(incname), "%s/%s", ServerRoot, value);
 
@@ -794,8 +782,8 @@ read_configuration(FILE *fp)                /* I - File to read from */
          * Send browse data to the named interface...
          */
 
-         strncpy(Browsers[NumBrowsers].iface, value + 4,
-                 sizeof(Browsers[0].iface) - 1);
+         strlcpy(Browsers[NumBrowsers].iface, value + 4,
+                 sizeof(Browsers[0].iface));
 
           nameptr = Browsers[NumBrowsers].iface +
                    strlen(Browsers[NumBrowsers].iface) - 1;
@@ -1246,8 +1234,7 @@ read_configuration(FILE *fp)              /* I - File to read from */
         if (*valueptr)
           *valueptr++ = '\0';
 
-        strncpy(SystemGroups[i], value, sizeof(SystemGroups[0]));
-       SystemGroups[i][sizeof(SystemGroups[0]) - 1] = '\0';
+        strlcpy(SystemGroups[i], value, sizeof(SystemGroups[0]));
 
         while (*value == ',' || isspace(*value))
          value ++;
@@ -1381,8 +1368,7 @@ read_configuration(FILE *fp)              /* I - File to read from */
            break;
 
        case VAR_STRING :
-           strncpy((char *)var->ptr, value, var->size - 1);
-           value[var->size - 1] = '\0';
+           strlcpy((char *)var->ptr, value, var->size);
            break;
       }
     }
@@ -1844,8 +1830,7 @@ get_address(char               *value,            /* I - Value string */
          * Hostname is a port number...
          */
 
-         strncpy(portname, hostname, sizeof(portname) - 1);
-         portname[sizeof(portname) - 1] = '\0';
+         strlcpy(portname, hostname, sizeof(portname));
          hostname[0] = '\0';
        }
         else
@@ -1897,5 +1882,5 @@ get_address(char               *value,            /* I - Value string */
 
 
 /*
- * End of "$Id: conf.c,v 1.102 2002/05/15 01:52:17 mike Exp $".
+ * End of "$Id: conf.c,v 1.103 2002/05/16 13:44:59 mike Exp $".
  */
index f39ef137c1cdb37a678601bf27286cb43f89d471..d03b3756e553a46483fe0073ad5b2fca04e5cbe2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: cups-lpd.c,v 1.32 2002/04/29 17:25:26 mike Exp $"
+ * "$Id: cups-lpd.c,v 1.33 2002/05/16 13:44:59 mike Exp $"
  *
  *   Line Printer Daemon interface for the Common UNIX Printing System (CUPS).
  *
@@ -139,10 +139,7 @@ main(int  argc,                    /* I - Number of command-line arguments */
     hostent  = gethostbyaddr((void *)&(hostaddr.sin_addr), hostlen, AF_INET);
 
     if (hostent)
-    {
-      strncpy(hostname, hostent->h_name, sizeof(hostname) - 1);
-      hostname[sizeof(hostname) - 1] = '\0';
-    }
+      strlcpy(hostname, hostent->h_name, sizeof(hostname));
     else
     {
       snprintf(hostname, sizeof(hostname), "%d.%d.%d.%d",
@@ -441,8 +438,7 @@ recv_print_job(const char    *dest, /* I - Destination */
 
   control[0] = '\0';
 
-  strncpy(queue, dest, sizeof(queue) - 1);
-  queue[sizeof(queue) - 1] = '\0';
+  strlcpy(queue, dest, sizeof(queue));
 
   if ((instance = strrchr(queue, '/')) != NULL)
     *instance++ = '\0';
@@ -548,8 +544,7 @@ recv_print_job(const char    *dest, /* I - Destination */
            break;
          }
 
-         strncpy(data[num_data], name, sizeof(data[0]) - 1);
-         data[num_data][sizeof(data[0]) - 1] = '\0';
+         strlcpy(data[num_data], name, sizeof(data[0]));
 
           if ((fd = cupsTempFd(temp[num_data], sizeof(temp[0]))) < 0)
          {
@@ -654,16 +649,13 @@ recv_print_job(const char    *dest,       /* I - Destination */
        switch (line[0])
        {
          case 'J' : /* Job name */
-             strncpy(title, line + 1, sizeof(title) - 1);
-             title[sizeof(title) - 1] = '\0';
+             strlcpy(title, line + 1, sizeof(title));
              break;
          case 'N' : /* Document name */
-             strncpy(docname, line + 1, sizeof(docname) - 1);
-             docname[sizeof(docname) - 1] = '\0';
+             strlcpy(docname, line + 1, sizeof(docname));
              break;
          case 'P' : /* User identification */
-             strncpy(user, line + 1, sizeof(user) - 1);
-             user[sizeof(user) - 1] = '\0';
+             strlcpy(user, line + 1, sizeof(user));
              break;
          case 'L' : /* Print banner page */
              banner = 1;
@@ -962,8 +954,7 @@ send_state(const char *dest,                /* I - Destination */
   * Remove instance from destination, if any...
   */
 
-  strncpy(queue, dest, sizeof(queue) - 1);
-  queue[sizeof(queue) - 1] = '\0';
+  strlcpy(queue, dest, sizeof(queue));
 
   if ((instance = strrchr(queue, '/')) != NULL)
     *instance++ = '\0';
@@ -1212,10 +1203,7 @@ send_state(const char *dest,             /* I - Destination */
          snprintf(namestr, sizeof(namestr), "%d copies of %s", jobcopies,
                   jobname);
        else
-       {
-         strncpy(namestr, jobname, sizeof(namestr) - 1);
-         namestr[sizeof(namestr) - 1] = '\0';
-       }
+         strlcpy(namestr, jobname, sizeof(namestr));
 
         printf("%s: %-34.34s[job %d localhost]\n", jobuser, rankstr, jobid);
         printf("        %-40.40s%d bytes\n", namestr, jobsize);
@@ -1301,5 +1289,5 @@ smart_gets(char *s,       /* I - Pointer to line buffer */
 
 
 /*
- * End of "$Id: cups-lpd.c,v 1.32 2002/04/29 17:25:26 mike Exp $".
+ * End of "$Id: cups-lpd.c,v 1.33 2002/05/16 13:44:59 mike Exp $".
  */
index cde82421273114e14eab361a1e3f5539c6f8b471..07d47ce663d8a6465d625c59a08f68992851ced1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: devices.c,v 1.16 2002/01/02 17:59:15 mike Exp $"
+ * "$Id: devices.c,v 1.17 2002/05/16 13:45:00 mike Exp $"
  *
  *   Device scanning routines for the Common UNIX Printing System (CUPS).
  *
@@ -225,11 +225,11 @@ LoadDevices(const char *d)        /* I - Directory to scan */
          num_devs ++;
 
          memset(dev, 0, sizeof(dev_info_t));
-         strncpy(dev->device_class, dclass, sizeof(dev->device_class) - 1);
-         strncpy(dev->device_info, info, sizeof(dev->device_info) - 1);
-         strncpy(dev->device_make_and_model, make_model,
-                 sizeof(dev->device_make_and_model) - 1);
-         strncpy(dev->device_uri, uri, sizeof(dev->device_uri) - 1);
+         strlcpy(dev->device_class, dclass, sizeof(dev->device_class));
+         strlcpy(dev->device_info, info, sizeof(dev->device_info));
+         strlcpy(dev->device_make_and_model, make_model,
+                 sizeof(dev->device_make_and_model));
+         strlcpy(dev->device_uri, uri, sizeof(dev->device_uri));
 
           LogMessage(L_DEBUG, "LoadDevices: Added device \"%s\"...", uri);
          count ++;
@@ -282,7 +282,7 @@ LoadDevices(const char *d)  /* I - Directory to scan */
        snprintf(dev->device_info, sizeof(dev->device_info),
                 "Unknown Network Device (%s)", dent->d_name);
        strcpy(dev->device_make_and_model, "Unknown");
-       strncpy(dev->device_uri, dent->d_name, sizeof(dev->device_uri) - 1);
+       strlcpy(dev->device_uri, dent->d_name, sizeof(dev->device_uri));
 
         LogMessage(L_DEBUG, "LoadDevices: Compatibility device \"%s\"...",
                   dent->d_name);
@@ -478,5 +478,5 @@ sigalrm_handler(int sig)    /* I - Signal number */
 
 
 /*
- * End of "$Id: devices.c,v 1.16 2002/01/02 17:59:15 mike Exp $".
+ * End of "$Id: devices.c,v 1.17 2002/05/16 13:45:00 mike Exp $".
  */
index 8c539570140abb5f286110c9acbdbf631283cc49..78dd5cfcba96f98339285c2bb5611763a57e416c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: dirsvc.c,v 1.94 2002/05/12 11:49:29 mike Exp $"
+ * "$Id: dirsvc.c,v 1.95 2002/05/16 13:45:00 mike Exp $"
  *
  *   Directory services routines for the Common UNIX Printing System (CUPS).
  *
@@ -139,9 +139,8 @@ ProcessBrowseData(const char   *uri,        /* I - URI of printer/class */
 
          if (p->type & CUPS_PRINTER_REMOTE)
          {
-           /* No "p->var[sizeof(p->var) - 1] = '\0';" because p is zeroed */
-            strncat(p->name, "@", sizeof(p->name) - 1);
-           strncat(p->name, p->hostname, sizeof(p->name) - 1);
+            strlcat(p->name, "@", sizeof(p->name));
+           strlcat(p->name, p->hostname, sizeof(p->name));
            SetPrinterAttrs(p);
            SortPrinters();
          }
@@ -150,25 +149,20 @@ ProcessBrowseData(const char   *uri,      /* I - URI of printer/class */
        }
        else if (!p->hostname[0])
        {
-         /* No "p->var[sizeof(p->var) - 1] = '\0';" because p is zeroed */
-          strncpy(p->hostname, host, sizeof(p->hostname) - 1);
-         strncpy(p->uri, uri, sizeof(p->uri) - 1);
-         strncpy(p->device_uri, uri, sizeof(p->device_uri) - 1);
+          strlcpy(p->hostname, host, sizeof(p->hostname));
+         strlcpy(p->uri, uri, sizeof(p->uri));
+         strlcpy(p->device_uri, uri, sizeof(p->device_uri));
           update = 1;
         }
       }
       else
-      {
-        strncpy(name, resource + 9, sizeof(name) - 1);
-        name[sizeof(name) - 1] = '\0';
-      }
+        strlcpy(name, resource + 9, sizeof(name));
     }
     else if (p != NULL && !p->hostname[0])
     {
-      /* No "p->var[sizeof(p->var) - 1] = '\0';" because p is zeroed */
-      strncpy(p->hostname, host, sizeof(p->hostname) - 1);
-      strncpy(p->uri, uri, sizeof(p->uri) - 1);
-      strncpy(p->device_uri, uri, sizeof(p->device_uri) - 1);
+      strlcpy(p->hostname, host, sizeof(p->hostname));
+      strlcpy(p->uri, uri, sizeof(p->uri));
+      strlcpy(p->device_uri, uri, sizeof(p->device_uri));
       update = 1;
     }
 
@@ -187,10 +181,9 @@ ProcessBrowseData(const char   *uri,       /* I - URI of printer/class */
       */
 
       p->type = type;
-      /* No "p->var[sizeof(p->var) - 1] = '\0';" because p is zeroed */
-      strncpy(p->uri, uri, sizeof(p->uri) - 1);
-      strncpy(p->device_uri, uri, sizeof(p->device_uri) - 1);
-      strncpy(p->hostname, host, sizeof(p->hostname) - 1);
+      strlcpy(p->uri, uri, sizeof(p->uri));
+      strlcpy(p->device_uri, uri, sizeof(p->device_uri));
+      strlcpy(p->hostname, host, sizeof(p->hostname));
 
       update = 1;
     }
@@ -220,9 +213,8 @@ ProcessBrowseData(const char   *uri,        /* I - URI of printer/class */
 
          if (p->type & CUPS_PRINTER_REMOTE)
          {
-           /* No "p->var[sizeof(p->var) - 1] = '\0';" because p is zeroed */
-            strncat(p->name, "@", sizeof(p->name) - 1);
-           strncat(p->name, p->hostname, sizeof(p->name) - 1);
+            strlcat(p->name, "@", sizeof(p->name));
+           strlcat(p->name, p->hostname, sizeof(p->name));
            SetPrinterAttrs(p);
            SortPrinters();
          }
@@ -231,25 +223,20 @@ ProcessBrowseData(const char   *uri,      /* I - URI of printer/class */
        }
        else if (!p->hostname[0])
        {
-         /* No "p->var[sizeof(p->var) - 1] = '\0';" because p is zeroed */
-          strncpy(p->hostname, host, sizeof(p->hostname) - 1);
-         strncpy(p->uri, uri, sizeof(p->uri) - 1);
-         strncpy(p->device_uri, uri, sizeof(p->device_uri) - 1);
+          strlcpy(p->hostname, host, sizeof(p->hostname));
+         strlcpy(p->uri, uri, sizeof(p->uri));
+         strlcpy(p->device_uri, uri, sizeof(p->device_uri));
           update = 1;
         }
       }
       else
-      {
-        strncpy(name, resource + 10, sizeof(name) - 1);
-        name[sizeof(name) - 1] = '\0';
-      }
+        strlcpy(name, resource + 10, sizeof(name));
     }
     else if (p != NULL && !p->hostname[0])
     {
-      /* No "p->var[sizeof(p->var) - 1] = '\0';" because p is zeroed */
-      strncpy(p->hostname, host, sizeof(p->hostname) - 1);
-      strncpy(p->uri, uri, sizeof(p->uri) - 1);
-      strncpy(p->device_uri, uri, sizeof(p->device_uri) - 1);
+      strlcpy(p->hostname, host, sizeof(p->hostname));
+      strlcpy(p->uri, uri, sizeof(p->uri));
+      strlcpy(p->device_uri, uri, sizeof(p->device_uri));
       update = 1;
     }
 
@@ -268,10 +255,9 @@ ProcessBrowseData(const char   *uri,       /* I - URI of printer/class */
       */
 
       p->type = type;
-      /* No "p->var[sizeof(p->var) - 1] = '\0';" because p is zeroed */
-      strncpy(p->hostname, host, sizeof(p->hostname) - 1);
-      strncpy(p->uri, uri, sizeof(p->uri) - 1);
-      strncpy(p->device_uri, uri, sizeof(p->device_uri) - 1);
+      strlcpy(p->hostname, host, sizeof(p->hostname));
+      strlcpy(p->uri, uri, sizeof(p->uri));
+      strlcpy(p->device_uri, uri, sizeof(p->device_uri));
 
       update = 1;
     }
@@ -293,15 +279,13 @@ ProcessBrowseData(const char   *uri,      /* I - URI of printer/class */
 
   if (strcmp(p->location, location))
   {
-    /* No "p->var[sizeof(p->var) - 1] = '\0';" because p is zeroed */
-    strncpy(p->location, location, sizeof(p->location) - 1);
+    strlcpy(p->location, location, sizeof(p->location));
     update = 1;
   }
 
   if (strcmp(p->info, info))
   {
-    /* No "p->var[sizeof(p->var) - 1] = '\0';" because p is zeroed */
-    strncpy(p->info, info, sizeof(p->info) - 1);
+    strlcpy(p->info, info, sizeof(p->info));
     update = 1;
   }
 
@@ -320,8 +304,7 @@ ProcessBrowseData(const char   *uri,        /* I - URI of printer/class */
 
   if (strcmp(p->make_model, local_make_model))
   {
-    /* No "p->var[sizeof(p->var) - 1] = '\0';" because p is zeroed */
-    strncpy(p->make_model, local_make_model, sizeof(p->make_model) - 1);
+    strlcpy(p->make_model, local_make_model, sizeof(p->make_model));
     update = 1;
   }
 
@@ -1072,10 +1055,7 @@ UpdateCUPSBrowse(void)
     sprintf(srcname, "%d.%d.%d.%d", address >> 24, (address >> 16) & 255,
             (address >> 8) & 255, address & 255);
   else
-  {
-    strncpy(srcname, srchost->h_name, sizeof(srcname) - 1);
-    srcname[sizeof(srcname) - 1] = '\0';
-  }
+    strlcpy(srcname, srchost->h_name, sizeof(srcname));
 
   len = strlen(srcname);
 
@@ -1411,7 +1391,7 @@ SendSLPBrowse(printer_t *p)               /* I - Printer to register */
   if (p->type & CUPS_PRINTER_BIND)
   {
     if (finishings[0])
-      strncat(finishings, ",bind", sizeof(finishings) - 1);
+      strlcat(finishings, ",bind", sizeof(finishings));
     else
       strcpy(finishings, "bind");
   }
@@ -1419,7 +1399,7 @@ SendSLPBrowse(printer_t *p)               /* I - Printer to register */
   if (p->type & CUPS_PRINTER_PUNCH)
   {
     if (finishings[0])
-      strncat(finishings, ",punch", sizeof(finishings) - 1);
+      strlcat(finishings, ",punch", sizeof(finishings));
     else
       strcpy(finishings, "punch");
   }
@@ -1427,7 +1407,7 @@ SendSLPBrowse(printer_t *p)               /* I - Printer to register */
   if (p->type & CUPS_PRINTER_COVER)
   {
     if (finishings[0])
-      strncat(finishings, ",cover", sizeof(finishings) - 1);
+      strlcat(finishings, ",cover", sizeof(finishings));
     else
       strcpy(finishings, "cover");
   }
@@ -1435,7 +1415,7 @@ SendSLPBrowse(printer_t *p)               /* I - Printer to register */
   if (p->type & CUPS_PRINTER_SORT)
   {
     if (finishings[0])
-      strncat(finishings, ",sort", sizeof(finishings) - 1);
+      strlcat(finishings, ",sort", sizeof(finishings));
     else
       strcpy(finishings, "sort");
   }
@@ -1443,8 +1423,6 @@ SendSLPBrowse(printer_t *p)               /* I - Printer to register */
   if (!finishings[0])
     strcpy(finishings, "none");
 
-  finishings[sizeof(finishings) - 1] = '\0';
-
  /*
   * Quote any commas in the make and model, location, and info strings
   * (local strings are twice the size of the ones in the printer_t
@@ -1732,7 +1710,7 @@ SrvUrlCallback(SLPHandle      hslp,       /* I - SLP handle */
   * Copy the SLP service URL...
   */
 
-  strncpy(s->url, srvurl, sizeof(s->url));
+  strlcpy(s->url, srvurl, sizeof(s->url));
 
  /* 
   * Link the SLP service URL into the head of the list
@@ -1839,5 +1817,5 @@ UpdateSLPBrowse(void)
 
 
 /*
- * End of "$Id: dirsvc.c,v 1.94 2002/05/12 11:49:29 mike Exp $".
+ * End of "$Id: dirsvc.c,v 1.95 2002/05/16 13:45:00 mike Exp $".
  */
index 50d50e5b7309f05fbfc888c7f681d11944988c6e..6f175fde1126eb54a222b465a6657169c934f4f3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: filter.c,v 1.4 2002/01/02 17:59:15 mike Exp $"
+ * "$Id: filter.c,v 1.5 2002/05/16 13:45:00 mike Exp $"
  *
  *   File type conversion routines for the Common UNIX Printing System (CUPS).
  *
@@ -88,8 +88,7 @@ mimeAddFilter(mime_t      *mime,      /* I - MIME database */
     if (temp->cost > cost)
     {
       temp->cost = cost;
-      strncpy(temp->filter, filter, sizeof(temp->filter) - 1);
-      temp->filter[sizeof(temp->filter) - 1] = '\0';
+      strlcpy(temp->filter, filter, sizeof(temp->filter));
     }
   }
   else
@@ -117,8 +116,7 @@ mimeAddFilter(mime_t      *mime,    /* I - MIME database */
     temp->src  = src;
     temp->dst  = dst;
     temp->cost = cost;
-    strncpy(temp->filter, filter, sizeof(temp->filter) - 1);
-    temp->filter[sizeof(temp->filter) - 1] = '\0';
+    strlcpy(temp->filter, filter, sizeof(temp->filter));
 
     if (mime->num_filters > 1)
       qsort(mime->filters, mime->num_filters, sizeof(mime_filter_t),
@@ -297,5 +295,5 @@ lookup(mime_t      *mime,   /* I - MIME database */
 
 
 /*
- * End of "$Id: filter.c,v 1.4 2002/01/02 17:59:15 mike Exp $".
+ * End of "$Id: filter.c,v 1.5 2002/05/16 13:45:00 mike Exp $".
  */
index 8903d7b504debbd66c98fec1451e5e487248d24b..85854b38d02973e75d6457ca2fc73ed9bffc07ab 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: ipp.c,v 1.158 2002/05/15 01:52:17 mike Exp $"
+ * "$Id: ipp.c,v 1.159 2002/05/16 13:45:01 mike Exp $"
  *
  *   IPP routines for the Common UNIX Printing System (CUPS) scheduler.
  *
@@ -658,16 +658,10 @@ add_class(client_t        *con,           /* I - Client connection */
   */
 
   if ((attr = ippFindAttribute(con->request, "printer-location", IPP_TAG_TEXT)) != NULL)
-  {
-    strncpy(pclass->location, attr->values[0].string.text, sizeof(pclass->location) - 1);
-    pclass->location[sizeof(pclass->location) - 1] = '\0';
-  }
+    strlcpy(pclass->location, attr->values[0].string.text, sizeof(pclass->location));
 
   if ((attr = ippFindAttribute(con->request, "printer-info", IPP_TAG_TEXT)) != NULL)
-  {
-    strncpy(pclass->info, attr->values[0].string.text, sizeof(pclass->info) - 1);
-    pclass->info[sizeof(pclass->info) - 1] = '\0';
-  }
+    strlcpy(pclass->info, attr->values[0].string.text, sizeof(pclass->info));
 
   if ((attr = ippFindAttribute(con->request, "printer-is-accepting-jobs", IPP_TAG_BOOLEAN)) != NULL)
   {
@@ -696,19 +690,16 @@ add_class(client_t        *con,           /* I - Client connection */
     pclass->browse_time = 0;
   }
   if ((attr = ippFindAttribute(con->request, "printer-state-message", IPP_TAG_TEXT)) != NULL)
-  {
-    strncpy(pclass->state_message, attr->values[0].string.text,
-            sizeof(pclass->state_message) - 1);
-    pclass->state_message[sizeof(pclass->state_message) - 1] = '\0';
-  }
+    strlcpy(pclass->state_message, attr->values[0].string.text,
+            sizeof(pclass->state_message));
   if ((attr = ippFindAttribute(con->request, "job-sheets-default", IPP_TAG_ZERO)) != NULL &&
       !Classification[0])
   {
-    strncpy(pclass->job_sheets[0], attr->values[0].string.text,
-            sizeof(pclass->job_sheets[0]) - 1);
+    strlcpy(pclass->job_sheets[0], attr->values[0].string.text,
+            sizeof(pclass->job_sheets[0]));
     if (attr->num_values > 1)
-      strncpy(pclass->job_sheets[1], attr->values[1].string.text,
-              sizeof(pclass->job_sheets[1]) - 1);
+      strlcpy(pclass->job_sheets[1], attr->values[1].string.text,
+              sizeof(pclass->job_sheets[1]));
     else
       strcpy(pclass->job_sheets[1], "none");
   }
@@ -1081,16 +1072,12 @@ add_printer(client_t        *con,       /* I - Client connection */
   */
 
   if ((attr = ippFindAttribute(con->request, "printer-location", IPP_TAG_TEXT)) != NULL)
-  {
-    strncpy(printer->location, attr->values[0].string.text, sizeof(printer->location) - 1);
-    printer->location[sizeof(printer->location) - 1] = '\0';
-  }
+    strlcpy(printer->location, attr->values[0].string.text,
+            sizeof(printer->location));
 
   if ((attr = ippFindAttribute(con->request, "printer-info", IPP_TAG_TEXT)) != NULL)
-  {
-    strncpy(printer->info, attr->values[0].string.text, sizeof(printer->info) - 1);
-    printer->info[sizeof(printer->info) - 1] = '\0';
-  }
+    strlcpy(printer->info, attr->values[0].string.text,
+            sizeof(printer->info));
 
   if ((attr = ippFindAttribute(con->request, "device-uri", IPP_TAG_URI)) != NULL)
   {
@@ -1136,9 +1123,8 @@ add_printer(client_t        *con, /* I - Client connection */
     LogMessage(L_INFO, "Setting %s device-uri to \"%s\" (was \"%s\".)",
                printer->name, attr->values[0].string.text, printer->device_uri);
 
-    strncpy(printer->device_uri, attr->values[0].string.text,
-            sizeof(printer->device_uri) - 1);
-    printer->device_uri[sizeof(printer->device_uri) - 1] = '\0';
+    strlcpy(printer->device_uri, attr->values[0].string.text,
+            sizeof(printer->device_uri));
   }
 
   if ((attr = ippFindAttribute(con->request, "printer-is-accepting-jobs", IPP_TAG_BOOLEAN)) != NULL)
@@ -1168,19 +1154,16 @@ add_printer(client_t        *con,       /* I - Client connection */
     printer->browse_time = 0;
   }
   if ((attr = ippFindAttribute(con->request, "printer-state-message", IPP_TAG_TEXT)) != NULL)
-  {
-    strncpy(printer->state_message, attr->values[0].string.text,
-            sizeof(printer->state_message) - 1);
-    printer->state_message[sizeof(printer->state_message) - 1] = '\0';
-  }
+    strlcpy(printer->state_message, attr->values[0].string.text,
+            sizeof(printer->state_message));
   if ((attr = ippFindAttribute(con->request, "job-sheets-default", IPP_TAG_ZERO)) != NULL &&
       !Classification[0])
   {
-    strncpy(printer->job_sheets[0], attr->values[0].string.text,
-            sizeof(printer->job_sheets[0]) - 1);
+    strlcpy(printer->job_sheets[0], attr->values[0].string.text,
+            sizeof(printer->job_sheets[0]));
     if (attr->num_values > 1)
-      strncpy(printer->job_sheets[1], attr->values[1].string.text,
-              sizeof(printer->job_sheets[1]) - 1);
+      strlcpy(printer->job_sheets[1], attr->values[1].string.text,
+              sizeof(printer->job_sheets[1]));
     else
       strcpy(printer->job_sheets[1], "none");
   }
@@ -1239,10 +1222,7 @@ add_printer(client_t        *con,        /* I - Client connection */
   */
 
   if (con->filename[0])
-  {
-    strncpy(srcfile, con->filename, sizeof(srcfile) - 1);
-    srcfile[sizeof(srcfile) - 1] = '\0';
-  }
+    strlcpy(srcfile, con->filename, sizeof(srcfile));
   else if ((attr = ippFindAttribute(con->request, "ppd-name", IPP_TAG_NAME)) != NULL)
   {
     if (strcmp(attr->values[0].string.text, "raw") == 0)
@@ -1761,17 +1741,13 @@ check_quotas(client_t  *con,    /* I - Client connection */
   attr = ippFindAttribute(con->request, "requesting-user-name", IPP_TAG_NAME);
 
   if (con->username[0])
-  {
-    strncpy(username, con->username, sizeof(username) - 1);
-    username[sizeof(username) - 1] = '\0';
-  }
+    strlcpy(username, con->username, sizeof(username));
   else if (attr != NULL)
   {
     LogMessage(L_DEBUG, "check_quotas: requesting-user-name = \'%s\'",
                attr->values[0].string.text);
 
-    strncpy(username, attr->values[0].string.text, sizeof(username) - 1);
-    username[sizeof(username) - 1] = '\0';
+    strlcpy(username, attr->values[0].string.text, sizeof(username));
   }
   else
     strcpy(username, "anonymous");
@@ -2189,23 +2165,19 @@ create_job(client_t        *con,        /* I - Client connection */
   job->attrs   = con->request;
   con->request = NULL;
 
-  strncpy(job->title, title, sizeof(job->title) - 1);
+  strlcpy(job->title, title, sizeof(job->title));
 
   attr = ippFindAttribute(job->attrs, "requesting-user-name", IPP_TAG_NAME);
 
   if (con->username[0])
-  {
-    strncpy(job->username, con->username, sizeof(job->username) - 1);
-    job->username[sizeof(job->username) - 1] = '\0';
-  }
+    strlcpy(job->username, con->username, sizeof(job->username));
   else if (attr != NULL)
   {
     LogMessage(L_DEBUG, "create_job: requesting-user-name = \'%s\'",
                attr->values[0].string.text);
 
-    strncpy(job->username, attr->values[0].string.text,
-            sizeof(job->username) - 1);
-    job->username[sizeof(job->username) - 1] = '\0';
+    strlcpy(job->username, attr->values[0].string.text,
+            sizeof(job->username));
   }
   else
     strcpy(job->username, "anonymous");
@@ -3022,15 +2994,9 @@ get_jobs(client_t        *con,           /* I - Client connection */
       attr->values[0].boolean)
   {
     if (con->username[0])
-    {
-      strncpy(username, con->username, sizeof(username) - 1);
-      username[sizeof(username) - 1] = '\0';
-    }
+      strlcpy(username, con->username, sizeof(username));
     else if ((attr = ippFindAttribute(con->request, "requesting-user-name", IPP_TAG_NAME)) != NULL)
-    {
-      strncpy(username, attr->values[0].string.text, sizeof(username) - 1);
-      username[sizeof(username) - 1] = '\0';
-    }
+      strlcpy(username, attr->values[0].string.text, sizeof(username));
     else
       strcpy(username, "anonymous");
   }
@@ -4047,22 +4013,18 @@ print_job(client_t        *con,         /* I - Client connection */
   * Copy the rest of the job info...
   */
 
-  strncpy(job->title, title, sizeof(job->title) - 1);
+  strlcpy(job->title, title, sizeof(job->title));
 
   attr = ippFindAttribute(job->attrs, "requesting-user-name", IPP_TAG_NAME);
 
   if (con->username[0])
-  {
-    strncpy(job->username, con->username, sizeof(job->username) - 1);
-    job->username[sizeof(job->username) - 1] = '\0';
-  }
+    strlcpy(job->username, con->username, sizeof(job->username));
   else if (attr != NULL)
   {
     LogMessage(L_DEBUG, "print_job: requesting-user-name = \'%s\'",
                attr->values[0].string.text);
 
-    strncpy(job->username, attr->values[0].string.text, sizeof(job->username) - 1);
-    job->username[sizeof(job->username) - 1] = '\0';
+    strlcpy(job->username, attr->values[0].string.text, sizeof(job->username));
   }
   else
     strcpy(job->username, "anonymous");
@@ -4407,11 +4369,8 @@ reject_jobs(client_t        *con,        /* I - Client connection */
                                IPP_TAG_TEXT)) == NULL)
     strcpy(printer->state_message, "Rejecting Jobs");
   else
-  {
-    strncpy(printer->state_message, attr->values[0].string.text,
-            sizeof(printer->state_message) - 1);
-    printer->state_message[sizeof(printer->state_message) - 1] = '\0';
-  }
+    strlcpy(printer->state_message, attr->values[0].string.text,
+            sizeof(printer->state_message));
 
   if (dtype == CUPS_PRINTER_CLASS)
     SaveAllClasses();
@@ -5329,7 +5288,7 @@ set_job_attrs(client_t        *con,       /* I - Client connection */
       */
 
       if (strcmp(attr->name, "job-name") == 0)
-        strncpy(job->title, attr->values[0].string.text, sizeof(job->title) - 1);
+        strlcpy(job->title, attr->values[0].string.text, sizeof(job->title));
       else if (strcmp(attr->name, "job-hold-until") == 0)
       {
         SetJobHoldUntil(job->id, attr->values[0].string.text);
@@ -5552,9 +5511,8 @@ stop_printer(client_t        *con,        /* I - Client connection */
     strcpy(printer->state_message, "Paused");
   else
   {
-    strncpy(printer->state_message, attr->values[0].string.text,
-            sizeof(printer->state_message) - 1);
-    printer->state_message[sizeof(printer->state_message) - 1] = '\0';
+    strlcpy(printer->state_message, attr->values[0].string.text,
+            sizeof(printer->state_message));
   }
 
   if (dtype == CUPS_PRINTER_CLASS)
@@ -5718,13 +5676,11 @@ validate_user(client_t   *con,          /* I - Client connection */
   */
 
   if (con->username[0])
-    strncpy(username, con->username, userlen - 1);
+    strlcpy(username, con->username, userlen);
   else if ((attr = ippFindAttribute(con->request, "requesting-user-name", IPP_TAG_NAME)) != NULL)
-    strncpy(username, attr->values[0].string.text, userlen - 1);
+    strlcpy(username, attr->values[0].string.text, userlen);
   else
-    strncpy(username, "anonymous", userlen - 1);
-
-  username[userlen - 1] = '\0';
+    strlcpy(username, "anonymous", userlen);
 
  /*
   * Check the username against the owner...
@@ -5775,5 +5731,5 @@ validate_user(client_t   *con,            /* I - Client connection */
 
 
 /*
- * End of "$Id: ipp.c,v 1.158 2002/05/15 01:52:17 mike Exp $".
+ * End of "$Id: ipp.c,v 1.159 2002/05/16 13:45:01 mike Exp $".
  */
index 1c588905795c43dc93b8f8c565431ffdd726ee9b..93400b38a6c51fe0004788fe7e8df330bc61e899 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: job.c,v 1.153 2002/05/15 01:52:18 mike Exp $"
+ * "$Id: job.c,v 1.154 2002/05/16 13:45:01 mike Exp $"
  *
  *   Job management routines for the Common UNIX Printing System (CUPS).
  *
@@ -91,7 +91,7 @@ AddJob(int        priority,   /* I - Job priority */
 
   job->id       = NextJobId ++;
   job->priority = priority;
-  strncpy(job->dest, dest, sizeof(job->dest) - 1);
+  strlcpy(job->dest, dest, sizeof(job->dest));
 
   NumJobs ++;
 
@@ -585,7 +585,7 @@ LoadAllJobs(void)
        continue;
       }
 
-      strncpy(job->dest, dest, sizeof(job->dest) - 1);
+      strlcpy(job->dest, dest, sizeof(job->dest));
 
       job->sheets     = ippFindAttribute(job->attrs, "job-media-sheets-completed",
                                          IPP_TAG_INTEGER);
@@ -595,12 +595,12 @@ LoadAllJobs(void)
       job->priority = attr->values[0].integer;
 
       attr = ippFindAttribute(job->attrs, "job-name", IPP_TAG_NAME);
-      strncpy(job->title, attr->values[0].string.text,
-              sizeof(job->title) - 1);
+      strlcpy(job->title, attr->values[0].string.text,
+              sizeof(job->title));
 
       attr = ippFindAttribute(job->attrs, "job-originating-user-name", IPP_TAG_NAME);
-      strncpy(job->username, attr->values[0].string.text,
-              sizeof(job->username) - 1);
+      strlcpy(job->username, attr->values[0].string.text,
+              sizeof(job->username));
 
       if (job->state->values[0].integer == IPP_JOB_HELD)
       {
@@ -728,7 +728,7 @@ MoveJob(int        id,              /* I - Job ID */
       if (current->state->values[0].integer >= IPP_JOB_PROCESSING)
         break;
 
-      strncpy(current->dest, dest, sizeof(current->dest) - 1);
+      strlcpy(current->dest, dest, sizeof(current->dest));
       current->dtype = p->type & (CUPS_PRINTER_CLASS | CUPS_PRINTER_REMOTE);
 
       if ((attr = ippFindAttribute(current->attrs, "job-printer-uri", IPP_TAG_URI)) != NULL)
@@ -1259,10 +1259,7 @@ StartJob(int       id,           /* I - Job ID */
     else if (strcmp(attr->name, "job-name") == 0 &&
             (attr->value_tag == IPP_TAG_NAME ||
              attr->value_tag == IPP_TAG_NAMELANG))
-    {
-      strncpy(title, attr->values[0].string.text, sizeof(title) - 1);
-      title[sizeof(title) - 1] = '\0';
-    }
+      strlcpy(title, attr->values[0].string.text, sizeof(title));
     else if (attr->group_tag == IPP_TAG_JOB)
     {
      /*
@@ -1299,18 +1296,18 @@ StartJob(int       id,          /* I - Job ID */
       */
 
       if (optptr > options)
-       strncat(optptr, " ", sizeof(options) - (optptr - options) - 1);
+       strlcat(optptr, " ", sizeof(options) - (optptr - options));
 
       if (attr->value_tag != IPP_TAG_BOOLEAN)
       {
-       strncat(optptr, attr->name, sizeof(options) - (optptr - options) - 1);
-       strncat(optptr, "=", sizeof(options) - (optptr - options) - 1);
+       strlcat(optptr, attr->name, sizeof(options) - (optptr - options));
+       strlcat(optptr, "=", sizeof(options) - (optptr - options));
       }
 
       for (i = 0; i < attr->num_values; i ++)
       {
        if (i)
-         strncat(optptr, ",", sizeof(options) - (optptr - options) - 1);
+         strlcat(optptr, ",", sizeof(options) - (optptr - options));
 
        optptr += strlen(optptr);
 
@@ -1318,17 +1315,17 @@ StartJob(int       id,          /* I - Job ID */
        {
          case IPP_TAG_INTEGER :
          case IPP_TAG_ENUM :
-             snprintf(optptr, sizeof(options) - (optptr - options) - 1,
+             snprintf(optptr, sizeof(options) - (optptr - options),
                       "%d", attr->values[i].integer);
              break;
 
          case IPP_TAG_BOOLEAN :
              if (!attr->values[i].boolean)
-               strncat(optptr, "no", sizeof(options) - (optptr - options) - 1);
+               strlcat(optptr, "no", sizeof(options) - (optptr - options));
 
          case IPP_TAG_NOVALUE :
-             strncat(optptr, attr->name,
-                     sizeof(options) - (optptr - options) - 1);
+             strlcat(optptr, attr->name,
+                     sizeof(options) - (optptr - options));
              break;
 
          case IPP_TAG_RANGE :
@@ -1359,14 +1356,14 @@ StartJob(int       id,          /* I - Job ID */
                  strchr(attr->values[i].string.text, '\t') != NULL ||
                  strchr(attr->values[i].string.text, '\n') != NULL)
              {
-               strncat(optptr, "\'", sizeof(options) - (optptr - options) - 1);
-               strncat(optptr, attr->values[i].string.text,
-                       sizeof(options) - (optptr - options) - 1);
-               strncat(optptr, "\'", sizeof(options) - (optptr - options) - 1);
+               strlcat(optptr, "\'", sizeof(options) - (optptr - options));
+               strlcat(optptr, attr->values[i].string.text,
+                       sizeof(options) - (optptr - options));
+               strlcat(optptr, "\'", sizeof(options) - (optptr - options));
              }
              else
-               strncat(optptr, attr->values[i].string.text,
-                       sizeof(options) - (optptr - options) - 1);
+               strlcat(optptr, attr->values[i].string.text,
+                       sizeof(options) - (optptr - options));
              break;
 
           default :
@@ -1588,10 +1585,7 @@ StartJob(int       id,           /* I - Job ID */
       snprintf(command, sizeof(command), "%s/filter/%s", ServerBin,
                filters[i].filter);
     else
-    {
-      strncpy(command, filters[i].filter, sizeof(command) - 1);
-      command[sizeof(command) - 1] = '\0';
-    }
+      strlcpy(command, filters[i].filter, sizeof(command));
 
     if (i < (num_filters - 1) ||
        strncmp(printer->device_uri, "file:", 5) != 0)
@@ -1946,8 +1940,8 @@ UpdateJob(job_t *job)             /* I - Job to check */
 
       if ((loglevel == L_INFO && !job->status) ||
          loglevel < L_INFO)
-        strncpy(job->printer->state_message, message,
-                sizeof(job->printer->state_message) - 1);
+        strlcpy(job->printer->state_message, message,
+                sizeof(job->printer->state_message));
     }
 
    /*
@@ -3062,5 +3056,5 @@ start_process(const char *command,        /* I - Full path to command */
 
 
 /*
- * End of "$Id: job.c,v 1.153 2002/05/15 01:52:18 mike Exp $".
+ * End of "$Id: job.c,v 1.154 2002/05/16 13:45:01 mike Exp $".
  */
index 36e0016dcb215786e637f2c6aca486100fc551a7..d65653b1c3d29cb58809e516f5b4b7dfe9d9b908 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: log.c,v 1.25 2002/05/14 01:14:29 mike Exp $"
+ * "$Id: log.c,v 1.26 2002/05/16 13:45:02 mike Exp $"
  *
  *   Log file routines for the Common UNIX Printing System (CUPS).
  *
@@ -354,8 +354,8 @@ check_log_file(FILE       **log,    /* IO - Log file */
 
     if (logname[0] != '/')
     {
-      strncpy(filename, ServerRoot, sizeof(filename) - 1);
-      strncat(filename, "/", sizeof(filename) - 1);
+      strlcpy(filename, ServerRoot, sizeof(filename));
+      strlcat(filename, "/", sizeof(filename));
     }
     else
       filename[0] = '\0';
@@ -376,7 +376,7 @@ check_log_file(FILE       **log,    /* IO - Log file */
          * Insert the server name...
          */
 
-         strncpy(ptr, ServerName, sizeof(filename) - (ptr - filename) - 1);
+         strlcpy(ptr, ServerName, sizeof(filename) - (ptr - filename));
          ptr += strlen(ptr);
        }
         else
@@ -424,8 +424,7 @@ check_log_file(FILE       **log,    /* IO - Log file */
     fclose(*log);
 
     strcpy(backname, filename);
-    strncat(backname, ".O", sizeof(backname) - 1);
-    backname[sizeof(backname) - 1] = '\0';
+    strlcat(backname, ".O", sizeof(backname));
 
     unlink(backname);
     rename(filename, backname);
@@ -442,5 +441,5 @@ check_log_file(FILE       **log,    /* IO - Log file */
 
 
 /*
- * End of "$Id: log.c,v 1.25 2002/05/14 01:14:29 mike Exp $".
+ * End of "$Id: log.c,v 1.26 2002/05/16 13:45:02 mike Exp $".
  */
index 0b5e062d844936fe4f41cab5ee5213c620f00efe..75c9637ca493b6c771fdb6424f4c44746914ec1d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: main.c,v 1.71 2002/05/12 11:49:29 mike Exp $"
+ * "$Id: main.c,v 1.72 2002/05/16 13:45:02 mike Exp $"
  *
  *   Scheduler main loop for the Common UNIX Printing System (CUPS).
  *
@@ -114,8 +114,7 @@ main(int  argc,                     /* I - Number of command-line arguments */
                * Absolute directory...
                */
 
-               strncpy(ConfigurationFile, argv[i], sizeof(ConfigurationFile) - 1);
-               ConfigurationFile[sizeof(ConfigurationFile) - 1] = '\0';
+               strlcpy(ConfigurationFile, argv[i], sizeof(ConfigurationFile));
               }
              else
              {
@@ -124,9 +123,8 @@ main(int  argc,                     /* I - Number of command-line arguments */
                */
 
                 getcwd(ConfigurationFile, sizeof(ConfigurationFile));
-               strncat(ConfigurationFile, "/", sizeof(ConfigurationFile) - 1);
-               strncat(ConfigurationFile, argv[i], sizeof(ConfigurationFile) - 1);
-               ConfigurationFile[sizeof(ConfigurationFile) - 1] = '\0';
+               strlcat(ConfigurationFile, "/", sizeof(ConfigurationFile));
+               strlcat(ConfigurationFile, argv[i], sizeof(ConfigurationFile));
               }
              break;
 
@@ -806,5 +804,5 @@ usage(void)
 
 
 /*
- * End of "$Id: main.c,v 1.71 2002/05/12 11:49:29 mike Exp $".
+ * End of "$Id: main.c,v 1.72 2002/05/16 13:45:02 mike Exp $".
  */
index 3f8b5c470fb6c2630b71cc0c04a417f3cbdb941f..368f570e1136108b68bcaf2885b27796eccd1262 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: mime.c,v 1.11 2002/05/14 01:14:30 mike Exp $"
+ * "$Id: mime.c,v 1.12 2002/05/16 13:45:02 mike Exp $"
  *
  *   MIME database file routines for the Common UNIX Printing System (CUPS).
  *
@@ -131,8 +131,7 @@ mimeMerge(mime_t     *mime, /* I - MIME database to add to */
   if (pathname == NULL)
     return (NULL);
 
-  strncpy(filename, pathname, sizeof(filename) - 1);
-  filename[sizeof(filename) - 1] = '\0';
+  strlcpy(filename, pathname, sizeof(filename));
 
   pathsep = filename + strlen(filename);
   if ((pathsep - filename + 9) > sizeof(filename))
@@ -508,10 +507,7 @@ load_convs(mime_t     *mime,               /* I - MIME database */
     */
 
     if (filter[0] == '/')
-    {
-      strncpy(filterprog, filter, sizeof(filterprog) - 1);
-      filterprog[sizeof(filterprog) - 1] = '\0';
-    }
+      strlcpy(filterprog, filter, sizeof(filterprog));
     else
       snprintf(filterprog, sizeof(filterprog), "%s/%s", filterpath, filter);
 
@@ -597,5 +593,5 @@ delete_rules(mime_magic_t *rules)   /* I - Rules to free */
 
 
 /*
- * End of "$Id: mime.c,v 1.11 2002/05/14 01:14:30 mike Exp $".
+ * End of "$Id: mime.c,v 1.12 2002/05/16 13:45:02 mike Exp $".
  */
index 5bbd7812668a6001948899a0fdd2b97d8998c8c4..e52d7287e3e237aadbb67c0ddb5a799ee240ae29 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: network.c,v 1.8 2002/04/02 18:58:53 mike Exp $"
+ * "$Id: network.c,v 1.9 2002/05/16 13:45:02 mike Exp $"
  *
  *   Network interface functions for the Common UNIX Printing System
  *   (CUPS) scheduler.
@@ -180,7 +180,7 @@ NetIFUpdate(void)
     * Then copy all of the information...
     */
 
-    strncpy(temp->name, addr->ifa_name, sizeof(temp->name) - 1);
+    strlcpy(temp->name, addr->ifa_name, sizeof(temp->name));
     memcpy(&(temp->address), addr->ifa_addr, sizeof(temp->address));
     memcpy(&(temp->mask), addr->ifa_netmask, sizeof(temp->mask));
 
@@ -215,11 +215,11 @@ NetIFUpdate(void)
     */
 
     if (host != NULL)
-      strncpy(temp->hostname, host->h_name, sizeof(temp->hostname) - 1);
+      strlcpy(temp->hostname, host->h_name, sizeof(temp->hostname));
     else if (ntohl(temp->address.sin_addr.s_addr) == 0x7f000001)
       strcpy(temp->hostname, "localhost");
     else if (temp->address.sin_addr.s_addr == ServerAddr.sin_addr.s_addr)
-      strncpy(temp->hostname, ServerName, sizeof(temp->hostname) - 1);
+      strlcpy(temp->hostname, ServerName, sizeof(temp->hostname));
     else
     {
       unsigned ip = ntohl(temp->address.sin_addr.s_addr);
@@ -470,5 +470,5 @@ freeifaddrs(struct ifaddrs *addrs)  /* I - Interface list to free */
 
 
 /*
- * End of "$Id: network.c,v 1.8 2002/04/02 18:58:53 mike Exp $".
+ * End of "$Id: network.c,v 1.9 2002/05/16 13:45:02 mike Exp $".
  */
index dd91d1d78d9cfdeaaad9b958e87f2d9621a7fb96..f7e55b4a5ed2e4cd5ffebb7cedac8087c272d4b1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: ppds.c,v 1.22 2002/01/02 17:59:17 mike Exp $"
+ * "$Id: ppds.c,v 1.23 2002/05/16 13:45:03 mike Exp $"
  *
  *   PPD scanning routines for the Common UNIX Printing System (CUPS).
  *
@@ -518,10 +518,7 @@ load_ppds(const char *d,           /* I - Actual directory */
     if (p[0])
       snprintf(name, sizeof(name), "%s/%s", p, dent->d_name);
     else
-    {
-      strncpy(name, dent->d_name, sizeof(name) - 1);
-      name[sizeof(name) - 1] = '\0';
-    }
+      strlcpy(name, dent->d_name, sizeof(name));
 
     if (stat(filename, &fileinfo))
       continue;
@@ -658,7 +655,7 @@ load_ppds(const char *d,            /* I - Actual directory */
       * Nope, copy the first part of the make and model then...
       */
 
-      strncpy(manufacturer, make_model, sizeof(manufacturer) - 1);
+      strlcpy(manufacturer, make_model, sizeof(manufacturer));
 
      /*
       * Truncate at the first space, dash, or slash, or make the
@@ -807,14 +804,14 @@ load_ppds(const char *d,          /* I - Actual directory */
     ppd->record.ppd_mtime = fileinfo.st_mtime;
     ppd->record.ppd_size  = fileinfo.st_size;
 
-    strncpy(ppd->record.ppd_name, name,
-            sizeof(ppd->record.ppd_name) - 1);
-    strncpy(ppd->record.ppd_make, manufacturer,
-            sizeof(ppd->record.ppd_make) - 1);
-    strncpy(ppd->record.ppd_make_and_model, make_model,
-            sizeof(ppd->record.ppd_make_and_model) - 1);
-    strncpy(ppd->record.ppd_natural_language, language,
-            sizeof(ppd->record.ppd_natural_language) - 1);
+    strlcpy(ppd->record.ppd_name, name,
+            sizeof(ppd->record.ppd_name));
+    strlcpy(ppd->record.ppd_make, manufacturer,
+            sizeof(ppd->record.ppd_make));
+    strlcpy(ppd->record.ppd_make_and_model, make_model,
+            sizeof(ppd->record.ppd_make_and_model));
+    strlcpy(ppd->record.ppd_natural_language, language,
+            sizeof(ppd->record.ppd_natural_language));
 
     changed_ppd = 1;
 
@@ -893,5 +890,5 @@ ppd_gets(buf_t *fp,         /* I - File to read from */
 
 
 /*
- * End of "$Id: ppds.c,v 1.22 2002/01/02 17:59:17 mike Exp $".
+ * End of "$Id: ppds.c,v 1.23 2002/05/16 13:45:03 mike Exp $".
  */
index eadad2f6cbc1836ebfebfd2642ae8249562d1656..e008bd48c3ef14d894d60ac8727e788c7b8d55f7 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: printers.c,v 1.121 2002/05/15 21:00:00 mike Exp $"
+ * "$Id: printers.c,v 1.122 2002/05/16 13:45:03 mike Exp $"
  *
  *   Printer routines for the Common UNIX Printing System (CUPS).
  *
@@ -93,8 +93,8 @@ AddPrinter(const char *name)  /* I - Name of printer */
   if ((p = calloc(1, sizeof(printer_t))) == NULL)
     return (NULL);
 
-  strncpy(p->name, name, sizeof(p->name) - 1);
-  strncpy(p->hostname, ServerName, sizeof(p->hostname) - 1);
+  strlcpy(p->name, name, sizeof(p->name));
+  strlcpy(p->hostname, ServerName, sizeof(p->hostname));
   snprintf(p->uri, sizeof(p->uri), "ipp://%s:%d/printers/%s", ServerName,
            ntohs(Listeners[0].address.sin_port), name);
 
@@ -597,11 +597,11 @@ LoadAllPrinters(void)
       return;
     }
     else if (strcmp(name, "Info") == 0)
-      strncpy(p->info, value, sizeof(p->info) - 1);
+      strlcpy(p->info, value, sizeof(p->info));
     else if (strcmp(name, "Location") == 0)
-      strncpy(p->location, value, sizeof(p->location) - 1);
+      strlcpy(p->location, value, sizeof(p->location));
     else if (strcmp(name, "DeviceURI") == 0)
-      strncpy(p->device_uri, value, sizeof(p->device_uri) - 1);
+      strlcpy(p->device_uri, value, sizeof(p->device_uri));
     else if (strcmp(name, "State") == 0)
     {
      /*
@@ -622,7 +622,7 @@ LoadAllPrinters(void)
       while (isspace(*value))
         value ++;
 
-      strncpy(p->state_message, value, sizeof(p->state_message) - 1);
+      strlcpy(p->state_message, value, sizeof(p->state_message));
     }
     else if (strcmp(name, "Accepting") == 0)
     {
@@ -646,7 +646,7 @@ LoadAllPrinters(void)
       if (*valueptr)
         *valueptr++ = '\0';
 
-      strncpy(p->job_sheets[0], value, sizeof(p->job_sheets[0]) - 1);
+      strlcpy(p->job_sheets[0], value, sizeof(p->job_sheets[0]));
 
       while (isspace(*valueptr))
         valueptr ++;
@@ -658,7 +658,7 @@ LoadAllPrinters(void)
        if (*valueptr)
           *valueptr++ = '\0';
 
-       strncpy(p->job_sheets[1], value, sizeof(p->job_sheets[1]) - 1);
+       strlcpy(p->job_sheets[1], value, sizeof(p->job_sheets[1]));
       }
     }
     else if (strcmp(name, "AllowUser") == 0)
@@ -1221,9 +1221,9 @@ SetPrinterAttrs(printer_t *p)             /* I - Printer to setup */
                        "pages-per-minute", ppd->throughput);
 
         if (ppd->nickname)
-          strncpy(p->make_model, ppd->nickname, sizeof(p->make_model) - 1);
+          strlcpy(p->make_model, ppd->nickname, sizeof(p->make_model));
        else if (ppd->modelname)
-          strncpy(p->make_model, ppd->modelname, sizeof(p->make_model) - 1);
+          strlcpy(p->make_model, ppd->modelname, sizeof(p->make_model));
        else
          strcpy(p->make_model, "Bad PPD File");
 
@@ -1667,8 +1667,7 @@ ValidateDest(const char   *hostname,      /* I - Host name */
   if (strcasecmp(hostname, "localhost") == 0)
     hostname = ServerName;
 
-  strncpy(localname, hostname, sizeof(localname) - 1);
-  localname[sizeof(localname) - 1] = '\0';
+  strlcpy(localname, hostname, sizeof(localname));
 
   if (strcasecmp(hostname, ServerName) != 0)
   {
@@ -2076,5 +2075,5 @@ write_irix_state(printer_t *p)    /* I - Printer to update */
 
 
 /*
- * End of "$Id: printers.c,v 1.121 2002/05/15 21:00:00 mike Exp $".
+ * End of "$Id: printers.c,v 1.122 2002/05/16 13:45:03 mike Exp $".
  */
index add38421b2afed276762f113864ff2f9568e1ef6..97d3da02d090c8b240a65a0b3115839c060f4ac4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: quotas.c,v 1.6 2002/01/02 17:59:18 mike Exp $"
+ * "$Id: quotas.c,v 1.7 2002/05/16 13:45:03 mike Exp $"
  *
  *   Quota routines for the Common UNIX Printing System (CUPS).
  *
@@ -71,7 +71,7 @@ AddQuota(printer_t  *p,                       /* I - Printer */
   p->num_quotas ++;
 
   memset(q, 0, sizeof(quota_t));
-  strncpy(q->username, username, sizeof(q->username) - 1);
+  strlcpy(q->username, username, sizeof(q->username));
 
   if (p->num_quotas > 1)
     qsort(p->quotas, p->num_quotas, sizeof(quota_t),
@@ -100,8 +100,7 @@ FindQuota(printer_t  *p,            /* I - Printer */
     q = NULL;
   else
   {
-    strncpy(match.username, username, sizeof(match.username) - 1);
-    match.username[sizeof(match.username) - 1] = '\0';
+    strlcpy(match.username, username, sizeof(match.username));
 
     q = bsearch(&match, p->quotas, p->num_quotas, sizeof(quota_t),
                 (int(*)(const void *, const void *))compare);
@@ -232,5 +231,5 @@ compare(const quota_t *q1,          /* I - First quota record */
 
 
 /*
- * End of "$Id: quotas.c,v 1.6 2002/01/02 17:59:18 mike Exp $".
+ * End of "$Id: quotas.c,v 1.7 2002/05/16 13:45:03 mike Exp $".
  */
index 37841cb95ff220ec6e9588efe2f24d4eb24c3795..746eeee7fbc880a190d1cf157997b582238d55d2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: type.c,v 1.15 2002/05/14 01:14:30 mike Exp $"
+ * "$Id: type.c,v 1.16 2002/05/16 13:45:03 mike Exp $"
  *
  *   MIME typing routines for the Common UNIX Printing System (CUPS).
  *
@@ -109,7 +109,7 @@ mimeAddType(mime_t     *mime,       /* I - MIME database */
   mime->num_types ++;
 
   *types = temp;
-  strncpy(temp->super, super, sizeof(temp->super) - 1);
+  strlcpy(temp->super, super, sizeof(temp->super));
   if ((temp->type = strdup(type)) == NULL)
   {
     mime->num_types --;
@@ -619,8 +619,7 @@ mimeType(mime_t     *mime,  /* I - MIME database */
   * Lookup the type in the array...
   */
 
-  strncpy(key.super, super, sizeof(key.super) - 1);
-  key.super[sizeof(key.super) - 1] = '\0';
+  strlcpy(key.super, super, sizeof(key.super));
   key.type = (char *)type;
 
   keyptr = &key;
@@ -1093,5 +1092,5 @@ patmatch(const char *s,           /* I - String to match against */
 
 
 /*
- * End of "$Id: type.c,v 1.15 2002/05/14 01:14:30 mike Exp $".
+ * End of "$Id: type.c,v 1.16 2002/05/16 13:45:03 mike Exp $".
  */
index 5c2d2d784b7acd33308a606db0cf8598f65a37e3..353cfecdc51c1722ee06e14f3c81bcb60fa95b25 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: accept.c,v 1.15 2002/01/02 17:59:19 mike Exp $"
+ * "$Id: accept.c,v 1.16 2002/05/16 13:45:04 mike Exp $"
  *
  *   "accept", "disable", "enable", and "reject" commands for the Common
  *   UNIX Printing System (CUPS).
@@ -178,10 +178,7 @@ main(int  argc,                    /* I - Number of command-line arguments */
       */
 
       if (sscanf(argv[i], "%1023[^@]@%1023s", printer, hostname) == 1)
-      {
-       strncpy(hostname, server, sizeof(hostname) - 1);
-       hostname[sizeof(hostname) - 1] = '\0';
-      }
+       strlcpy(hostname, server, sizeof(hostname));
 
       if (http != NULL && strcasecmp(http->hostname, hostname) != 0)
       {
@@ -312,5 +309,5 @@ main(int  argc,                     /* I - Number of command-line arguments */
 
 
 /*
- * End of "$Id: accept.c,v 1.15 2002/01/02 17:59:19 mike Exp $".
+ * End of "$Id: accept.c,v 1.16 2002/05/16 13:45:04 mike Exp $".
  */
index 394f500fc1b547155af3b238b3547b6e3f511b0e..6d07a2ee1e483fea5d1041536935d7765d0a097a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: cancel.c,v 1.22 2002/01/02 17:59:19 mike Exp $"
+ * "$Id: cancel.c,v 1.23 2002/05/16 13:45:04 mike Exp $"
  *
  *   "cancel" command for the Common UNIX Printing System (CUPS).
  *
@@ -163,8 +163,7 @@ main(int  argc,                     /* I - Number of command-line arguments */
       }
       else
       {
-        strncpy(name, argv[i], sizeof(name) - 1);
-       name[sizeof(name) - 1] = '\0';
+        strlcpy(name, argv[i], sizeof(name));
 
        dest   = name;
         job_id = 0;
@@ -282,5 +281,5 @@ main(int  argc,                     /* I - Number of command-line arguments */
 
 
 /*
- * End of "$Id: cancel.c,v 1.22 2002/01/02 17:59:19 mike Exp $".
+ * End of "$Id: cancel.c,v 1.23 2002/05/16 13:45:04 mike Exp $".
  */
index d3d317f2c7ff98b0682e91254287cb7d25167dc8..69612a42b7b2ec518d963992ff954b26a6d5e5cd 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: cupsaddsmb.c,v 1.7 2002/04/05 15:37:19 mike Exp $"
+ * "$Id: cupsaddsmb.c,v 1.8 2002/05/16 13:45:04 mike Exp $"
  *
  *   "cupsaddsmb" command for the Common UNIX Printing System (CUPS).
  *
@@ -187,10 +187,7 @@ do_samba_command(const char *command,      /* I - Command to run */
     if (Verbosity)
       printf("Running command: %s\n", temp);
     else
-    {
-      strncat(temp, " </dev/null >/dev/null 2>/dev/null", sizeof(temp) - 1);
-      temp[sizeof(temp) - 1] = '\0';
-    }
+      strlcat(temp, " </dev/null >/dev/null 2>/dev/null", sizeof(temp));
 
     if ((status = system(temp)) != 0)
     {
@@ -339,5 +336,5 @@ usage()
 
 
 /*
- * End of "$Id: cupsaddsmb.c,v 1.7 2002/04/05 15:37:19 mike Exp $".
+ * End of "$Id: cupsaddsmb.c,v 1.8 2002/05/16 13:45:04 mike Exp $".
  */
index 7eb8a95d1e4268392d10271a16eec169f8784bb3..8453d6efc0c234dbdf5226db517c2c1a282c1b87 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: lpadmin.c,v 1.29 2002/03/14 19:11:12 mike Exp $"
+ * "$Id: lpadmin.c,v 1.30 2002/05/16 13:45:04 mike Exp $"
  *
  *   "lpadmin" command for the Common UNIX Printing System (CUPS).
  *
@@ -1764,8 +1764,7 @@ set_printer_options(http_t        *http,  /* I - Server connection */
         * Get default option name...
        */
 
-        strncpy(keyword, line + 8, sizeof(keyword) - 1);
-       keyword[sizeof(keyword) - 1] = '\0';
+        strlcpy(keyword, line + 8, sizeof(keyword));
 
        for (keyptr = keyword; *keyptr; keyptr ++)
          if (*keyptr == ':' || isspace(*keyptr))
@@ -1864,5 +1863,5 @@ validate_name(const char *name)   /* I - Name to check */
 
 
 /*
- * End of "$Id: lpadmin.c,v 1.29 2002/03/14 19:11:12 mike Exp $".
+ * End of "$Id: lpadmin.c,v 1.30 2002/05/16 13:45:04 mike Exp $".
  */
index 3eb2bbf6984f4c5e8478ec744b25e6701878dc75..70c87dd82c3b9d45ecc89be4076e353a494709f7 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: ipptest.c,v 1.14 2002/04/09 19:27:07 mike Exp $"
+ * "$Id: ipptest.c,v 1.15 2002/05/16 13:45:05 mike Exp $"
  *
  *   IPP test command for the Common UNIX Printing System (CUPS).
  *
@@ -276,44 +276,44 @@ do_tests(const char *uri,         /* I - URI to connect on */
 
             if (strncasecmp(tempptr + 1, "uri", 3) == 0)
            {
-             strncpy(tokenptr, uri, sizeof(token) - 1 - (tokenptr - token));
+             strlcpy(tokenptr, uri, sizeof(token) - (tokenptr - token));
              tempptr += 4;
            }
            else if (strncasecmp(tempptr + 1, "method", 6) == 0)
            {
-             strncpy(tokenptr, method, sizeof(token) - 1 - (tokenptr - token));
+             strlcpy(tokenptr, method, sizeof(token) - (tokenptr - token));
              tempptr += 7;
            }
            else if (strncasecmp(tempptr + 1, "username", 8) == 0)
            {
-             strncpy(tokenptr, userpass, sizeof(token) - 1 - (tokenptr - token));
+             strlcpy(tokenptr, userpass, sizeof(token) - (tokenptr - token));
              tempptr += 9;
            }
            else if (strncasecmp(tempptr + 1, "hostname", 8) == 0)
            {
-             strncpy(tokenptr, server, sizeof(token) - 1 - (tokenptr - token));
+             strlcpy(tokenptr, server, sizeof(token) - (tokenptr - token));
              tempptr += 9;
            }
            else if (strncasecmp(tempptr + 1, "port", 4) == 0)
            {
-             snprintf(tokenptr, sizeof(token) - 1 - (tokenptr - token),
+             snprintf(tokenptr, sizeof(token) - (tokenptr - token),
                       "%d", port);
              tempptr += 5;
            }
            else if (strncasecmp(tempptr + 1, "resource", 8) == 0)
            {
-             strncpy(tokenptr, resource, sizeof(token) - 1 - (tokenptr - token));
+             strlcpy(tokenptr, resource, sizeof(token) - (tokenptr - token));
              tempptr += 9;
            }
            else if (strncasecmp(tempptr + 1, "job-id", 6) == 0)
            {
-             snprintf(tokenptr, sizeof(token) - 1 - (tokenptr - token),
+             snprintf(tokenptr, sizeof(token) - (tokenptr - token),
                       "%d", job_id);
              tempptr += 7;
            }
            else if (strncasecmp(tempptr + 1, "user", 4) == 0)
            {
-             strncpy(tokenptr, cupsUser(), sizeof(token) - 1 - (tokenptr - token));
+             strlcpy(tokenptr, cupsUser(), sizeof(token) - (tokenptr - token));
              tempptr += 5;
            }
             else
@@ -822,5 +822,5 @@ print_attr(ipp_attribute_t *attr)   /* I - Attribute to print */
 
 
 /*
- * End of "$Id: ipptest.c,v 1.14 2002/04/09 19:27:07 mike Exp $".
+ * End of "$Id: ipptest.c,v 1.15 2002/05/16 13:45:05 mike Exp $".
  */