]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
Verify that name lengths are at most AFSNAMEMAX and symlink
authorNickolai Zeldovich <kolya@mit.edu>
Sun, 21 Apr 2002 22:01:36 +0000 (22:01 +0000)
committerGarry Zacheiss <zacheiss@mit.edu>
Sun, 21 Apr 2002 22:01:36 +0000 (22:01 +0000)
contents are at most AFSPATHMAX (notably, the Linux kernel
doesn't check this for us); bug report by nneul@umr.edu.

(cherry picked from commit 41f047edf69ad7c6c83cfa94f410f0daa9bb91fd)

src/afs/VNOPS/afs_vnop_create.c
src/afs/VNOPS/afs_vnop_dirops.c
src/afs/VNOPS/afs_vnop_link.c
src/afs/VNOPS/afs_vnop_remove.c
src/afs/VNOPS/afs_vnop_rename.c
src/afs/VNOPS/afs_vnop_symlink.c

index 37ca0ff15398ec4988d6b38055923812ea0a766c..ede5d766754351497c2533dad2a7e25895a73733 100644 (file)
@@ -94,6 +94,11 @@ afs_create(OSI_VC_ARG(adp), aname, attrs, aexcl, amode, avcp, acred)
     }
 #endif
 
+    if (strlen(aname) > AFSNAMEMAX) {
+       code = ENAMETOOLONG;
+       goto done;
+    }
+
     if (!afs_ENameOK(aname)) {
        code = EINVAL;
        goto done;
index 10ebcfaca51f73e8fb82ad91d931d455221b0ce6..daf33b73812af96a82fc8899bde5c36350fde376 100644 (file)
@@ -72,6 +72,11 @@ afs_mkdir(OSI_VC_ARG(adp), aname, attrs, avcp, acred)
     if (code = afs_InitReq(&treq, acred)) 
        goto done2;
 
+    if (strlen(aname) > AFSNAMEMAX) {
+       code = ENAMETOOLONG;
+       goto done;
+    }
+
     if (!afs_ENameOK(aname)) {
        code = EINVAL;
        goto done;
@@ -198,6 +203,11 @@ afs_rmdir(adp, aname, acred)
     if (code = afs_InitReq(&treq, acred)) 
        goto done2;
 
+    if (strlen(aname) > AFSNAMEMAX) {
+       code = ENAMETOOLONG;
+       goto done;
+    }
+
     code = afs_VerifyVCache(adp, &treq);
     if (code) goto done;
 
index 5c9de0676151d25dd3d692dc618a24748267ab6f..2a727c918047068f75d77644d1388d05370febf0 100644 (file)
@@ -70,6 +70,10 @@ afs_link(avc, OSI_VC_ARG(adp), aname, acred)
        code = EXDEV;
        goto done;
     }
+    if (strlen(aname) > AFSNAMEMAX) {
+       code = ENAMETOOLONG;
+       goto done;
+    }
     code = afs_VerifyVCache(adp, &treq);
     if (code) goto done;
 
index ad65b6c0fc108627c2ee57ea531c3d97cc71b159..3bdb16cfdab1f697c9d20537190a19035ef251d3 100644 (file)
@@ -253,6 +253,13 @@ afs_remove(OSI_VC_ARG(adp), aname, acred)
 #endif
       return code;
     }
+    if (strlen(aname) > AFSNAMEMAX) {
+#ifdef  AFS_OSF_ENV
+       afs_PutVCache(adp, 0);
+       afs_PutVCache(tvc, 0);
+#endif
+       return ENAMETOOLONG;
+    }
 tagain:
     code = afs_VerifyVCache(adp, &treq);
 #ifdef AFS_OSF_ENV
index 7c86a1557d60bba3607d4bdf30b38a8e5a1f2341..e056df0b1167f02cb5aec22890aef5ea734043c8 100644 (file)
@@ -55,6 +55,11 @@ afsrename(aodp, aname1, andp, aname2, acred)
 
     if (code = afs_InitReq(&treq, acred)) return code;
 
+    if (strlen(aname1) > AFSNAMEMAX || strlen(aname2) > AFSNAMEMAX) {
+       code = ENAMETOOLONG;
+       goto done;
+    }
+
     /* verify the latest versions of the stat cache entries */
 tagain:
     code = afs_VerifyVCache(aodp, &treq);
index 5a0cf7e383a9ecead2e60b8bddb7fc196ba5900f..be105aefc8312459e566e77ed6ea906791b28f11 100644 (file)
@@ -78,6 +78,11 @@ afs_symlink
     afs_Trace2(afs_iclSetp, CM_TRACE_SYMLINK, ICL_TYPE_POINTER, adp,
                 ICL_TYPE_STRING, aname);
 
+    if (strlen(aname) > AFSNAMEMAX || strlen(atargetName) > AFSPATHMAX) {
+       code = ENAMETOOLONG;
+       goto done2;
+    }
+
     if (afs_IsDynroot(adp)) {
        code = afs_DynrootVOPSymlink(adp, acred, aname, atargetName);
        goto done2;