Prevent uafs_readdir/closedir segfault

Check for the NULL case in uafs_readdir/closedir, so we don't blindly
dereference the given pointer.

Change-Id: Iaefce9bf2e5135a60e9739f866a1f27333f06e28
Reviewed-on: http://gerrit.openafs.org/1715
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>
This commit is contained in:
Andrew Deason 2009-08-14 16:26:16 -05:00 committed by Derrick Brashear
parent 50f248d160
commit f7b1923642

View File

@ -3958,6 +3958,11 @@ uafs_readdir_r(usr_DIR * dirp)
struct usr_dirent *direntP;
struct min_direct *directP;
if (!dirp) {
errno = EBADF;
return NULL;
}
/*
* Make sure this is an open file
*/
@ -4045,6 +4050,11 @@ uafs_closedir_r(usr_DIR * dirp)
int fd;
int rc;
if (!dirp) {
errno = EBADF;
return -1;
}
fd = dirp->dd_fd;
afs_osi_Free((char *)dirp,
sizeof(usr_DIR) + USR_DIRSIZE + sizeof(struct usr_dirent));