]> arthur.barton.de Git - netatalk.git/commitdiff
Use strlcpy function.
authordidg <didg>
Sat, 14 Feb 2004 00:30:50 +0000 (00:30 +0000)
committerdidg <didg>
Sat, 14 Feb 2004 00:30:50 +0000 (00:30 +0000)
etc/afpd/auth.c
etc/afpd/messages.c
etc/afpd/uam.c
etc/atalkd/config.c
etc/atalkd/main.c
etc/papd/auth.c
etc/papd/uam.c
include/atalk/util.h
libatalk/dsi/dsi_tcp.c

index 53ca08acca20740709334a28b7ba3fbe46d201f2..b90f7534920d65b5d161401ef5ebdd8668f42891 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: auth.c,v 1.44.2.3.2.8 2003-12-12 19:16:32 didg Exp $
+ * $Id: auth.c,v 1.44.2.3.2.9 2004-02-14 00:30:50 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -932,7 +932,7 @@ int auth_load(const char *path, const char *list)
     if (!path || !*path || !list || (len = strlen(path)) > sizeof(name) - 2)
         return -1;
 
-    strncpy(buf, list, sizeof(buf));
+    strlcpy(buf, list, sizeof(buf));
     if ((p = strtok(buf, ",")) == NULL)
         return -1;
 
index 971e0e470b847a189918313fdd9c0411cf7ff54b..c30842ffa06e2dda3ce5adf29f9474332f90c7c4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: messages.c,v 1.16.6.1.2.6 2003-11-13 00:19:45 bfernhomberg Exp $
+ * $Id: messages.c,v 1.16.6.1.2.7 2004-02-14 00:30:50 didg Exp $
  *
  * Copyright (c) 1997 Adrian Sun (asun@zoology.washington.edu)
  * All Rights Reserved.  See COPYRIGHT.
@@ -18,6 +18,7 @@
 #include <stdlib.h>
 #include <atalk/afp.h>
 #include <atalk/dsi.h>
+#include <atalk/util.h>
 #include <atalk/logger.h>
 #include "globals.h"
 #include "misc.h"
@@ -31,7 +32,7 @@ static char localized_message[MAXPATHLEN] = "";
 
 void setmessage(const char *message)
 {
-    strncpy(servermesg, message, MAXMESGSIZE);
+    strlcpy(servermesg, message, MAXMESGSIZE);
 }
 
 void readmessage(obj)
index 93cdb8e76396b4e5aad7831ea6a7a37e46049139..85204d6db3fbecc1bf0ff7006a212949fb382ca1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: uam.c,v 1.24.6.3 2004-01-11 12:31:12 bfernhomberg Exp $
+ * $Id: uam.c,v 1.24.6.4 2004-02-14 00:30:51 didg Exp $
  *
  * Copyright (c) 1999 Adrian Sun (asun@zoology.washington.edu)
  * All Rights Reserved.  See COPYRIGHT.
@@ -93,8 +93,7 @@ struct uam_mod *uam_load(const char *path, const char *name)
         goto uam_load_fail;
     }
 
-    strncpy(buf, name, sizeof(buf));
-    buf[sizeof(buf) - 1] = '\0';
+    strlcpy(buf, name, sizeof(buf));
     if ((p = strchr(buf, '.')))
         *p = '\0';
 
@@ -332,8 +331,7 @@ struct passwd *uam_getname(void *private, char *name, const int len)
 
        if ( (strncasecmp_w((ucs2_t*)user, (ucs2_t*)username, len) == 0) || 
                ( strncasecmp_w ( (ucs2_t*) pwname, (ucs2_t*) username, len) == 0)) {
-            strncpy(name, pwent->pw_name, len);
-            name[len - 1] = '\0';
+            strlcpy(name, pwent->pw_name, len);
             break;
         }
     }
index 675949a66825c6fccf7d1dc8972e6624c7fd4b58..ed034d6131b3e0a7f47cb8fc3fce7f4a77a420be 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: config.c,v 1.13.6.2 2004-01-15 06:34:15 bfernhomberg Exp $
+ * $Id: config.c,v 1.13.6.3 2004-02-14 00:30:51 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved. See COPYRIGHT.
@@ -342,8 +342,7 @@ int readconf( cf )
         * Check that av[ 0 ] is a valid interface.
         * Not possible under sysV.
         */
-       strncpy( ifr.ifr_name, argv[ 0 ], sizeof(ifr.ifr_name) );
-       ifr.ifr_name[sizeof(ifr.ifr_name) - 1] = '\0';
+       strlcpy( ifr.ifr_name, argv[ 0 ], sizeof(ifr.ifr_name) );
 
        /* for devices that don't support appletalk */
        if ((ioctl(s, SIOCGIFADDR, &ifr) < 0) && (errno == ENODEV)) {
@@ -715,7 +714,7 @@ int getifconf()
 
     start = list = getifacelist();
     while (list && *list) {
-        strncpy(ifr.ifr_name, *list, sizeof(ifr.ifr_name));
+        strlcpy(ifr.ifr_name, *list, sizeof(ifr.ifr_name));
        list++;
 
        if (ioctl(s, SIOCGIFFLAGS, &ifr) < 0)
@@ -790,7 +789,7 @@ struct interface *newiface( name )
            == NULL ) {
        return( NULL );
     }
-    strncpy( niface->i_name, name, sizeof(niface->i_name));
+    strlcpy( niface->i_name, name, sizeof(niface->i_name));
 #ifdef BSD4_4
     niface->i_addr.sat_len = sizeof( struct sockaddr_at );
 #endif /* BSD4_4 */
index d4c4480c3c288bd87d7bf0df02bb520b9afbf418..8d8d87eb2212501c5f26addab404cce89486b7d5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: main.c,v 1.17.8.3 2004-01-21 00:20:57 lenneis Exp $
+ * $Id: main.c,v 1.17.8.4 2004-02-14 00:30:51 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved. See COPYRIGHT.
@@ -1415,7 +1415,7 @@ int set;
     }
 
     /* get interface config */
-    strncpy(ifr.ifr_name, iname, sizeof(ifr.ifr_name));
+    strlcpy(ifr.ifr_name, iname, sizeof(ifr.ifr_name));
     if (ioctl(sock, SIOCGIFFLAGS, &ifr) < 0) {
         close(sock);
         return (-1);
@@ -1428,7 +1428,7 @@ int set;
            ifr.ifr_flags &= ~IFF_ALLMULTI;
 
     /* set interface config */
-    strncpy(ifr.ifr_name, iname, sizeof(ifr.ifr_name));
+    strlcpy(ifr.ifr_name, iname, sizeof(ifr.ifr_name));
     if (ioctl(sock, SIOCSIFFLAGS, &ifr) < 0) {
         close(sock);   
         return -1;
index 8489128273107c7e3016f14e6dded813b3cbbe94..70dd04ad038e11db8886be7ade9e9385d0104a8e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: auth.c,v 1.6.8.1 2003-11-14 14:37:38 didg Exp $
+ * $Id: auth.c,v 1.6.8.2 2004-02-14 00:30:51 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -104,7 +104,7 @@ int auth_load(const char *path, const char *list)
   if (!path || !list || (len = strlen(path)) > sizeof(name) - 2)
     return -1;
 
-  strncpy(buf, list, sizeof(buf));
+  strlcpy(buf, list, sizeof(buf));
   if ((p = strtok(buf, ",")) == NULL)
     return -1;
 
@@ -115,7 +115,7 @@ int auth_load(const char *path, const char *list)
   }
 
   while (p) {
-    strncpy(name + len, p, sizeof(name) - len);
+    strlcpy(name + len, p, sizeof(name) - len);
     if ((stat(name, &st) == 0) && (mod = uam_load(name, p))) {
       uam_attach(&uam_modules, mod);
       LOG(log_info, logtype_papd, "uam: %s loaded", p);
index 8309ca3d160879900faa703289be75ca68bb7e2f..f1b368076e7c59c8572c824742e0b89dbd71d62c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: uam.c,v 1.9.6.3 2003-11-14 14:37:38 didg Exp $
+ * $Id: uam.c,v 1.9.6.4 2004-02-14 00:30:51 didg Exp $
  *
  * Copyright (c) 1999 Adrian Sun (asun@zoology.washington.edu)
  * All Rights Reserved.  See COPYRIGHT.
@@ -64,7 +64,7 @@ struct uam_mod *uam_load(const char *path, const char *name)
     goto uam_load_fail;
   }
 
-  strncpy(buf, name, sizeof(buf));
+  strlcpy(buf, name, sizeof(buf));
   if ((p = strchr(buf, '.')))
     *p = '\0';
   if ((mod->uam_fcn = mod_symbol(module, buf)) == NULL) {
index 2a8ec22fef1a1062d788cb194d6a47354957b3b9..5837942d958d1d263532074776b57c507b304a3f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: util.h,v 1.7.10.2 2003-10-17 00:01:12 didg Exp $
+ * $Id: util.h,v 1.7.10.3 2004-02-14 00:30:52 didg Exp $
  */
 
 #ifndef _ATALK_UTIL_H
@@ -34,6 +34,14 @@ extern pid_t server_lock  __P((char * /*program*/, char * /*file*/,
 extern void fault_setup          __P((void (*fn)(void *)));
 #define server_unlock(x)  (unlink(x))
 
+#ifndef HAVE_STRLCPY
+size_t strlcpy(char *d, const char *s, size_t bufsize);
+#endif
+#ifndef HAVE_STRLCAT
+size_t strlcat(char *d, const char *s, size_t bufsize);
+#endif
+
 #ifndef HAVE_DLFCN_H
 extern void *mod_open    __P((const char *));
 extern void *mod_symbol  __P((void *, const char *));
index 4bff873ca4ae524e6e256fc0018c44ea45b245f1..580ce12136371fa8b0f0a7f3827b02585fd746c9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: dsi_tcp.c,v 1.9.10.4 2004-02-11 16:06:15 didg Exp $
+ * $Id: dsi_tcp.c,v 1.9.10.5 2004-02-14 00:30:52 didg Exp $
  *
  * Copyright (c) 1997, 1998 Adrian Sun (asun@zoology.washington.edu)
  * All rights reserved. See COPYRIGHT.
@@ -308,8 +308,7 @@ int dsi_tcp_init(DSI *dsi, const char *hostname, const char *address,
       /* get it from the interface list */
       start = list = getifacelist();
       while (list && *list) {
-          strncpy(ifr.ifr_name, *list, sizeof(ifr.ifr_name));
-          ifr.ifr_name[sizeof(ifr.ifr_name) -1] = 0;          
+          strlcpy(ifr.ifr_name, *list, sizeof(ifr.ifr_name));
          list++;
 
 #ifndef IFF_SLAVE