]> arthur.barton.de Git - netatalk.git/commitdiff
more strncpy --> strlcpy fixes
authordidg <didg>
Sat, 14 Feb 2004 15:47:19 +0000 (15:47 +0000)
committerdidg <didg>
Sat, 14 Feb 2004 15:47:19 +0000 (15:47 +0000)
etc/afpd/auth.c
etc/afpd/mangle.c
etc/afpd/ofork.c
etc/afpd/volume.c
libatalk/adouble/ad_open.c

index b90f7534920d65b5d161401ef5ebdd8668f42891..c76234134b7d7257d389a95f928079de134c5fe9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: auth.c,v 1.44.2.3.2.9 2004-02-14 00:30:50 didg Exp $
+ * $Id: auth.c,v 1.44.2.3.2.10 2004-02-14 15:47:19 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -943,7 +943,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);
         LOG(log_debug, logtype_afpd, "uam: loading (%s)", name);
         /*
         if ((stat(name, &st) == 0) && (mod = uam_load(name, p))) {
index 38855a6389a846967bbb2f2b1d3647fe2a8d202a..4a6d9eb9bc5dd33a6dd6d04d4e4d8b4e07e60f67 100644 (file)
@@ -1,5 +1,5 @@
 /* 
- * $Id: mangle.c,v 1.16.2.1.2.7 2003-11-03 03:10:01 bfernhomberg Exp $ 
+ * $Id: mangle.c,v 1.16.2.1.2.8 2004-02-14 15:47:20 didg Exp $ 
  *
  * Copyright (c) 2002. Joe Marcus Clarke (marcus@marcuscom.com)
  * All Rights Reserved.  See COPYRIGHT.
 #include <ctype.h>
 #include "mangle.h"
 #include "desktop.h"
+#include <atalk/util.h>  
 
 #define hextoint( c )   ( isdigit( c ) ? c - '0' : c + 10 - 'A' )
 #define isuxdigit(x)    (isdigit(x) || (isupper(x) && isxdigit(x)))
 
-
-
 static char *demangle_checks ( const struct vol *vol, char* uname, char * mfilename, size_t prefix, char * ext)
 {
     u_int16_t flags;
@@ -229,10 +228,9 @@ mangle(const struct vol *vol, char *filename, char *uname, cnid_t id, int flags)
        }
     }
     m = mfilename;
-    memset(m, 0, MAX_LENGTH + 1);
     k = sprintf(mangle_suffix, "%c%X", MANGLE_CHAR, ntohl(id));
 
-    strncpy(m, filename, MAX_LENGTH - k - ext_len);
+    strlcpy(m, filename, MAX_LENGTH - k - ext_len +1);
     if (*m == 0) {
         strcat(m, "???");
     }
index 378d7c1b5e67c38f46f7cea8544bcf2f2e96779f..8d47061cd07f4097a4deb397f80b177007a02f96 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: ofork.c,v 1.20.6.3 2003-11-01 02:38:09 bfernhomberg Exp $
+ * $Id: ofork.c,v 1.20.6.4 2004-02-14 15:47:20 didg Exp $
  *
  * Copyright (c) 1996 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -20,7 +20,7 @@
 #include <atalk/logger.h>
 #include <errno.h>
 
-#include <atalk/adouble.h>
+#include <atalk/util.h>
 
 #include "globals.h"
 #include "volume.h"
@@ -120,7 +120,7 @@ const char *oldpath, *newpath;
         if (vol == of->of_vol && olddir == of->of_dir &&
                 s_of->key.dev == of->key.dev && 
                 s_of->key.inode == of->key.inode ) {
-            strncpy( of->of_name, newpath, of->of_namelen);
+            strlcpy( of->of_name, newpath, of->of_namelen);
             if (newdir != olddir) {
                 of->of_d_prev->of_d_next = of->of_d_next;
                 of->of_d_next->of_d_prev = of->of_d_prev;
@@ -253,7 +253,7 @@ struct stat     *st;
         oforks[ of_refnum ] = NULL;
         return NULL;
     }
-    strncpy( of->of_name, path, of->of_namelen = 255 + 1);
+    strlcpy( of->of_name, path, of->of_namelen = 255 + 1);
     *ofrefnum = refnum;
     of->of_refnum = refnum;
     of->key.dev = st->st_dev;
index 0dcf6321c5d0ef9a3d561e6b83a17f0c2d017355..f8e3f78a3fe2b46c91d9bfc10a20b96c1c0c2800 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: volume.c,v 1.51.2.7.2.19 2004-02-05 16:55:19 bfernhomberg Exp $
+ * $Id: volume.c,v 1.51.2.7.2.20 2004-02-14 15:47:20 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -210,7 +210,7 @@ static char *volxlate(AFPObj *obj, char *dest, size_t destlen,
     if (!ret) {
         return NULL;
     }
-    strncpy(dest, src, destlen);
+    strlcpy(dest, src, destlen +1);
     if ((p = strchr(src, '$')) == NULL) /* nothing to do */
         return ret;
 
@@ -692,7 +692,7 @@ const char *name;
     if (!args)
         return -1;
 
-    strncpy(buf, args, sizeof(buf));
+    strlcpy(buf, args, sizeof(buf));
     if ((p = strtok(buf, ",")) == NULL) /* nothing, return okay */
         return -1;
 
index 5fd833d1205e73f6e279f9ae171c307e7d064877..08cc7fb9673c984eb0c763329d9f0f38b182c24b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: ad_open.c,v 1.30.6.6 2004-02-06 13:39:52 bfernhomberg Exp $
+ * $Id: ad_open.c,v 1.30.6.7 2004-02-14 15:47:22 didg Exp $
  *
  * Copyright (c) 1999 Adrian Sun (asun@u.washington.edu)
  * Copyright (c) 1990,1991 Regents of The University of Michigan.
@@ -640,6 +640,8 @@ static int ad_header_read(struct adouble *ad, struct stat *hst)
  *         /   a/.AppleDouble/b
  *     a/b
  *         \   b/.AppleDouble/.Parent
+ *
+ * FIXME: should do something for pathname > MAXPATHLEN
  */
 char *
 ad_path( path, adflags )
@@ -648,27 +650,29 @@ ad_path( path, adflags )
 {
     static char        pathbuf[ MAXPATHLEN + 1];
     char       c, *slash, buf[MAXPATHLEN + 1];
+    size_t      l;
 
-    strncpy(buf, path, MAXPATHLEN);
+    l = strlcpy(buf, path, MAXPATHLEN +1);
     if ( adflags & ADFLAGS_DIR ) {
-       strncpy( pathbuf, buf, MAXPATHLEN );
-       if ( *buf != '\0' ) {
-           strcat( pathbuf, "/" );
+       strcpy( pathbuf, buf);
+       if ( *buf != '\0' && l < MAXPATHLEN) {
+           pathbuf[l++] = '/';
+           pathbuf[l] = 0;
        }
        slash = ".Parent";
     } else {
        if (NULL != ( slash = strrchr( buf, '/' )) ) {
            c = *++slash;
            *slash = '\0';
-           strncpy( pathbuf, buf, MAXPATHLEN);
+           strcpy( pathbuf, buf);
            *slash = c;
        } else {
            pathbuf[ 0 ] = '\0';
            slash = buf;
        }
     }
-    strncat( pathbuf, ".AppleDouble/", MAXPATHLEN - strlen(pathbuf));
-    strncat( pathbuf, slash, MAXPATHLEN - strlen(pathbuf));
+    strlcat( pathbuf, ".AppleDouble/", MAXPATHLEN +1);
+    strlcat( pathbuf, slash, MAXPATHLEN +1);
 
     return( pathbuf );
 }