Add a check for the return value of getcwd(). Fix another check
which mistakenly checks if the return value is less than zero
instead of checking whether the return value is NULL.
Signed-off-by: Ari Sundholm <ari@tuxera.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
(void)mkdir(dirname, 0777);
if (logname && logname[0] != '/') {
- if (getcwd(rpath, sizeof(rpath)) < 0){
+ if (!getcwd(rpath, sizeof(rpath))){
perror("getcwd failed");
exit(1);
}
}
top_ino = statbuf.st_ino;
homedir = getcwd(NULL, 0);
+ if (!homedir) {
+ perror("getcwd failed");
+ _exit(1);
+ }
seed += procid;
srandom(seed);
if (namerand)