mirror of
https://git.openafs.org/openafs.git
synced 2025-01-18 23:10:58 +00:00
dir: check afs_dir_Create return code in afs_dir_MakeDir
afs_dir_MakeDir() ignores the return code from afs_dir_Create() for the '.' and '..' ("dot" and "dotdot") directories. This has been the case from the earliest implementation (MakeDir() calling Create()) in the original IBM import. Instead, check the return codes to prevent the possibility of creating malformed directories. Change-Id: I60179488429dfa9afe60c4862c5e42b41f1e0048 Reviewed-on: https://gerrit.openafs.org/13800 Reviewed-by: Benjamin Kaduk <kaduk@mit.edu> Reviewed-by: Mark Vitale <mvitale@sinenomine.net> Tested-by: BuildBot <buildbot@rampaginggeek.com>
This commit is contained in:
parent
04805f48a2
commit
dcce956df4
@ -326,10 +326,17 @@ FreeBlobs(dir_file_t dir, int firstblob, int nblobs)
|
||||
DRelease(&pagehdbuf, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
/*!
|
||||
* Format an empty directory properly. Note that the first 13 entries in a
|
||||
* directory header page are allocated, 1 to the page header, 4 to the
|
||||
* allocation map and 8 to the hash table.
|
||||
*
|
||||
* \param dir pointer to the directory object
|
||||
* \param me fid (vnode+uniq) for new dir
|
||||
* \param parent fid (vnode+uniq) for parent dir
|
||||
*
|
||||
* \retval 0 success
|
||||
* \retval nonzero error code
|
||||
*/
|
||||
int
|
||||
afs_dir_MakeDir(dir_file_t dir, afs_int32 * me, afs_int32 * parent)
|
||||
@ -337,6 +344,7 @@ afs_dir_MakeDir(dir_file_t dir, afs_int32 * me, afs_int32 * parent)
|
||||
int i;
|
||||
struct DirBuffer buffer;
|
||||
struct DirHeader *dhp;
|
||||
int code;
|
||||
|
||||
DNew(dir, 0, &buffer);
|
||||
dhp = (struct DirHeader *)buffer.data;
|
||||
@ -354,8 +362,12 @@ afs_dir_MakeDir(dir_file_t dir, afs_int32 * me, afs_int32 * parent)
|
||||
for (i = 0; i < NHASHENT; i++)
|
||||
dhp->hashTable[i] = 0;
|
||||
DRelease(&buffer, 1);
|
||||
afs_dir_Create(dir, ".", me);
|
||||
afs_dir_Create(dir, "..", parent); /* Virtue is its own .. */
|
||||
code = afs_dir_Create(dir, ".", me);
|
||||
if (code)
|
||||
return code;
|
||||
code = afs_dir_Create(dir, "..", parent);
|
||||
if (code)
|
||||
return code;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user