Explicitly check path against NULL instead of relying on boolality. Yes, I just made that word up.
This commit is contained in:
@@ -82,7 +82,7 @@ faccessat(int fd, const char* path, int accessMode, int flag)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (path && path[0] == '/') {
|
if (path != NULL && path[0] == '/') {
|
||||||
// path is absolute, call access() ignoring fd
|
// path is absolute, call access() ignoring fd
|
||||||
return (flag & AT_EACCESS) == 0 ? eaccess(path, accessMode)
|
return (flag & AT_EACCESS) == 0 ? eaccess(path, accessMode)
|
||||||
: access(path, accessMode);
|
: access(path, accessMode);
|
||||||
@@ -153,7 +153,7 @@ fchmodat(int fd, const char* path, mode_t mode, int flag)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (path && path[0] == '/') {
|
if (path != NULL && path[0] == '/') {
|
||||||
// path is absolute, call chmod() ignoring fd
|
// path is absolute, call chmod() ignoring fd
|
||||||
return chmod(path, mode);
|
return chmod(path, mode);
|
||||||
}
|
}
|
||||||
@@ -222,7 +222,7 @@ fchownat(int fd, const char* path, uid_t owner, gid_t group, int flag)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (path && path[0] == '/') {
|
if (path != NULL && path[0] == '/') {
|
||||||
// path is absolute, call chown() ignoring fd
|
// path is absolute, call chown() ignoring fd
|
||||||
return chown(path, owner, group);
|
return chown(path, owner, group);
|
||||||
}
|
}
|
||||||
@@ -295,7 +295,7 @@ fstatat(int fd, const char *path, struct stat *st, int flag)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (path && path[0] == '/') {
|
if (path != NULL && path[0] == '/') {
|
||||||
// path is absolute, call stat() ignoring fd
|
// path is absolute, call stat() ignoring fd
|
||||||
return stat(path, st);
|
return stat(path, st);
|
||||||
}
|
}
|
||||||
@@ -352,7 +352,7 @@ fstatat(int fd, const char *path, struct stat *st, int flag)
|
|||||||
int
|
int
|
||||||
mkdirat(int fd, const char *path, mode_t mode)
|
mkdirat(int fd, const char *path, mode_t mode)
|
||||||
{
|
{
|
||||||
if (path && path[0] == '/') {
|
if (path != NULL && path[0] == '/') {
|
||||||
// path is absolute, call mkdir() ignoring fd
|
// path is absolute, call mkdir() ignoring fd
|
||||||
return mkdir(path, mode);
|
return mkdir(path, mode);
|
||||||
}
|
}
|
||||||
@@ -409,7 +409,7 @@ mkdirat(int fd, const char *path, mode_t mode)
|
|||||||
int
|
int
|
||||||
mkfifoat(int fd, const char *path, mode_t mode)
|
mkfifoat(int fd, const char *path, mode_t mode)
|
||||||
{
|
{
|
||||||
if (path && path[0] == '/') {
|
if (path != NULL && path[0] == '/') {
|
||||||
// path is absolute, call mkfifo() ignoring fd
|
// path is absolute, call mkfifo() ignoring fd
|
||||||
return mkfifo(path, mode);
|
return mkfifo(path, mode);
|
||||||
}
|
}
|
||||||
@@ -466,7 +466,7 @@ mkfifoat(int fd, const char *path, mode_t mode)
|
|||||||
int
|
int
|
||||||
mknodat(int fd, const char *path, mode_t mode, dev_t dev)
|
mknodat(int fd, const char *path, mode_t mode, dev_t dev)
|
||||||
{
|
{
|
||||||
if (path && path[0] == '/') {
|
if (path != NULL && path[0] == '/') {
|
||||||
// path is absolute, call mknod() ignoring fd
|
// path is absolute, call mknod() ignoring fd
|
||||||
return mknod(path, mode, dev);
|
return mknod(path, mode, dev);
|
||||||
}
|
}
|
||||||
@@ -524,10 +524,10 @@ renameat(int oldFD, const char* oldPath, int newFD, const char* newPath)
|
|||||||
bool oldPathIsAbsolute = false;
|
bool oldPathIsAbsolute = false;
|
||||||
bool newPathIsAbsolute = false;
|
bool newPathIsAbsolute = false;
|
||||||
|
|
||||||
if (oldPath && oldPath[0] == '/')
|
if (oldPath != NULL && oldPath[0] == '/')
|
||||||
oldPathIsAbsolute = true;
|
oldPathIsAbsolute = true;
|
||||||
|
|
||||||
if (newPath && newPath[0] == '/')
|
if (newPath != NULL && newPath[0] == '/')
|
||||||
newPathIsAbsolute = true;
|
newPathIsAbsolute = true;
|
||||||
|
|
||||||
if (oldPathIsAbsolute && newPathIsAbsolute) {
|
if (oldPathIsAbsolute && newPathIsAbsolute) {
|
||||||
@@ -630,7 +630,7 @@ renameat(int oldFD, const char* oldPath, int newFD, const char* newPath)
|
|||||||
ssize_t
|
ssize_t
|
||||||
readlinkat(int fd, const char *path, char *buffer, size_t bufferSize)
|
readlinkat(int fd, const char *path, char *buffer, size_t bufferSize)
|
||||||
{
|
{
|
||||||
if (path && path[0] == '/') {
|
if (path != NULL && path[0] == '/') {
|
||||||
// path is absolute, call readlink() ignoring fd
|
// path is absolute, call readlink() ignoring fd
|
||||||
return readlink(path, buffer, bufferSize);
|
return readlink(path, buffer, bufferSize);
|
||||||
}
|
}
|
||||||
@@ -687,7 +687,7 @@ readlinkat(int fd, const char *path, char *buffer, size_t bufferSize)
|
|||||||
int
|
int
|
||||||
symlinkat(const char *toPath, int fd, const char *symlinkPath)
|
symlinkat(const char *toPath, int fd, const char *symlinkPath)
|
||||||
{
|
{
|
||||||
if (symlinkPath && symlinkPath[0] == '/') {
|
if (symlinkPath != NULL && symlinkPath[0] == '/') {
|
||||||
// symlinkPath is absolute, call symlink() ignoring fd
|
// symlinkPath is absolute, call symlink() ignoring fd
|
||||||
return symlink(toPath, symlinkPath);
|
return symlink(toPath, symlinkPath);
|
||||||
}
|
}
|
||||||
@@ -744,7 +744,7 @@ symlinkat(const char *toPath, int fd, const char *symlinkPath)
|
|||||||
int
|
int
|
||||||
unlinkat(int fd, const char *path, int flag)
|
unlinkat(int fd, const char *path, int flag)
|
||||||
{
|
{
|
||||||
if (path && path[0] == '/') {
|
if (path != NULL && path[0] == '/') {
|
||||||
// path is absolute, call rmdir() or unlink() ignoring fd
|
// path is absolute, call rmdir() or unlink() ignoring fd
|
||||||
return (flag & AT_REMOVEDIR) == 0 ? rmdir(path) : unlink(path);
|
return (flag & AT_REMOVEDIR) == 0 ? rmdir(path) : unlink(path);
|
||||||
}
|
}
|
||||||
@@ -815,10 +815,10 @@ linkat(int oldFD, const char *oldPath, int newFD, const char *newPath,
|
|||||||
bool oldPathIsAbsolute = false;
|
bool oldPathIsAbsolute = false;
|
||||||
bool newPathIsAbsolute = false;
|
bool newPathIsAbsolute = false;
|
||||||
|
|
||||||
if (oldPath && oldPath[0] == '/')
|
if (oldPath != NULL && oldPath[0] == '/')
|
||||||
oldPathIsAbsolute = true;
|
oldPathIsAbsolute = true;
|
||||||
|
|
||||||
if (newPath && newPath[0] == '/')
|
if (newPath != NULL && newPath[0] == '/')
|
||||||
newPathIsAbsolute = true;
|
newPathIsAbsolute = true;
|
||||||
|
|
||||||
if (oldPathIsAbsolute && newPathIsAbsolute) {
|
if (oldPathIsAbsolute && newPathIsAbsolute) {
|
||||||
@@ -920,7 +920,7 @@ linkat(int oldFD, const char *oldPath, int newFD, const char *newPath,
|
|||||||
int
|
int
|
||||||
futimesat(int fd, const char *path, const struct timeval times[2])
|
futimesat(int fd, const char *path, const struct timeval times[2])
|
||||||
{
|
{
|
||||||
if (path && path[0] == '/') {
|
if (path != NULL && path[0] == '/') {
|
||||||
// path is absolute, call utimes() ignoring fd
|
// path is absolute, call utimes() ignoring fd
|
||||||
return utimes(path, times);
|
return utimes(path, times);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user