]> arthur.barton.de Git - netatalk.git/commitdiff
replace : l = strlen(x); strncpy(z,x,l) with memcpy(z,x,l), ie make it clearer that...
authordidg <didg>
Fri, 13 Feb 2004 22:32:17 +0000 (22:32 +0000)
committerdidg <didg>
Fri, 13 Feb 2004 22:32:17 +0000 (22:32 +0000)
etc/afpd/appl.c
etc/afpd/directory.c
etc/afpd/filedir.c

index c3a00189119b557d02f6dd6cee8e2d752c50e160..ababedf3f20557f070f706fb06f73b12b5982a75 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: appl.c,v 1.12.2.1 2003-05-10 10:33:16 didg Exp $
+ * $Id: appl.c,v 1.12.2.1.2.1 2004-02-13 22:32:17 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -134,7 +134,8 @@ u_short     mplen;
  * but uses upaths instead of mac format paths.
  *
  * The new way: dir and path refer to an app, path is a mac format
- * pathname.  makemacpath() builds a cname.
+ * pathname.  makemacpath() builds a cname. (zero is a path separator
+ * and it's not \0 terminated).
  *
  * See afp_getappl() for the backward compatiblity code.
  */
@@ -149,10 +150,14 @@ char      *path;
 
     p = mpath + mpathlen;
     p -= strlen( path );
-    strncpy( p, path, strlen( path ));
+    memcpy( p, path, strlen( path )); 
 
     while ( dir->d_parent != NULL ) {
         p -= strlen( dir->d_m_name ) + 1;
+        if (p < mpath) {
+            /* FIXME: pathname too long */
+            return NULL;
+        }
         strcpy( p, dir->d_m_name );
         dir = dir->d_parent;
     }
@@ -218,6 +223,9 @@ int         ibuflen, *rbuflen;
     }
     mpath = obj->newtmp;
     mp = makemacpath( mpath, AFPOBJ_TMPSIZ, curdir, path->m_name );
+    if (!mp) {
+        return AFPERR_PARAM;
+    }
     mplen =  mpath + AFPOBJ_TMPSIZ - mp;
 
     /* write the new appl entry at start of temporary file */
@@ -301,6 +309,10 @@ int                ibuflen, *rbuflen;
     }
     mpath = obj->newtmp;
     mp = makemacpath( mpath, AFPOBJ_TMPSIZ, curdir, path->m_name );
+    if (!mp) {
+        return AFPERR_PARAM ;
+    }
+
     mplen =  mpath + AFPOBJ_TMPSIZ - mp;
     cc = copyapplfile( sa.sdt_fd, tfd, mp, mplen );
     close( tfd );
index 536a2bdaf4f52b1214db8701f7a11fe1533cae4d..ffa896ff45bd49d2d4036b6a9fded6e380ae9b8a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: directory.c,v 1.71.2.4.2.8 2004-02-09 23:49:31 bfernhomberg Exp $
+ * $Id: directory.c,v 1.71.2.4.2.9 2004-02-13 22:32:18 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -1203,7 +1203,7 @@ struct dir        *dir;
         }
         *--p = '/';
         p -= n;
-        strncpy( p, u, n );
+        memcpy( p, u, n );
     }
     if ( d != curdir ) {
         n = strlen( vol->v_path );
@@ -1213,7 +1213,7 @@ struct dir        *dir;
         }
         *--p = '/';
         p -= n;
-        strncpy( p, vol->v_path, n );
+        memcpy( p, vol->v_path, n );
     }
     if ( chdir( p ) < 0 ) {
         switch (errno) {
index e9da430b72b4032ab45c8fefe3ca670a408a4e07..4838bee2e75d70e0417c0744987f33d3d527dfa2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: filedir.c,v 1.45.2.2.2.5 2004-01-08 03:50:56 bfernhomberg Exp $
+ * $Id: filedir.c,v 1.45.2.2.2.6 2004-02-13 22:32:18 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -625,7 +625,7 @@ char        *u;
     *p = '\0';
     len = strlen( u );
     p -= len;
-    strncpy( p, u, len );
+    memcpy( p, u, len );
     if (dir) for ( d = dir; d->d_parent; d = d->d_parent ) {
         u = d->d_u_name;
         len = strlen( u );
@@ -637,7 +637,7 @@ char        *u;
         }
         *--p = '/';
         p -= len;
-        strncpy( p, u, len );
+        memcpy( p, u, len );
     }
     len = strlen( vol->v_path );
     if (p -len -1 < path) {
@@ -645,7 +645,7 @@ char        *u;
     }
     *--p = '/';
     p -= len;
-    strncpy( p, vol->v_path, len );
+    memcpy( p, vol->v_path, len );
 
     return( p );
 }