]> 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, 24 Mar 2002 19:21:35 +0000 (19:21 +0000)
committerNickolai Zeldovich <kolya@mit.edu>
Sun, 24 Mar 2002 19:21:35 +0000 (19:21 +0000)
contents are at most AFSPATHMAX (notably, the Linux kernel
doesn't check this for us); bug report by nneul@umr.edu.

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 dc7c7134daef6004e89983e944e33e4ef2a06912..8e3eb32785a2ed00af946bab2cd9b89f70adcb8c 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 3f8dce80f3ac5358dcf08843e2d1c497d00d3aac..7dcb41b664d1b76a7ac89b15459ddd57c5a1e199 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;
@@ -200,6 +205,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 493363cef4968d0865e4d90ec30aebe639667eaa..29e4829585cc6baa16c0ff88096d9af738e44def 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 f946b3d66f4bfad29498ffe3c08d44fe87e00b75..2438301254eee948c0c6ab18c44f994716c426a9 100644 (file)
@@ -257,6 +257,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 4e60bc7203e81d55adc4380fd045254571ce6319..f1db55072a54c1b5558a154dd3eb2187804be432 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 678b0a778423e28cde64016ba622a641017d852e..637eb83233e6fd7b7743a57dd7d354b4b1ca3b11 100644 (file)
@@ -79,6 +79,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;