Move the invalid fd check to after checking if fd == AT_FDCWD in the fchownat() function
This commit is contained in:
parent
adf4838afe
commit
2f9bd2c090
@ -206,18 +206,18 @@ fchownat(int fd, const char* path, uid_t owner, gid_t group, int flag)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (fd < 0) {
|
||||
// Invalid file descriptor
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (fd == AT_FDCWD || path != NULL && path[0] == '/') {
|
||||
// call chown() ignoring fd
|
||||
return (flag & AT_SYMLINK_NOFOLLOW) != 0 ? lchown(path, owner, group)
|
||||
: chown(path, owner, group);
|
||||
}
|
||||
|
||||
if (fd < 0) {
|
||||
// Invalid file descriptor
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
}
|
||||
|
||||
char *fullPath = (char *)malloc(MAXPATHLEN);
|
||||
if (fullPath == NULL) {
|
||||
// ran out of memory allocating dirpath
|
||||
|
Loading…
x
Reference in New Issue
Block a user