bugfix + review suggestion

This commit is contained in:
Yakov Olkhovskiy 2023-03-06 21:24:04 -05:00 committed by GitHub
parent a8ceab1366
commit aacd05e34b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -170,7 +170,7 @@ int decompress(char * input, char * output, off_t start, off_t end, size_t max_n
bool isSudo()
{
return getuid() == 0 && geteuid() == 0 && getenv("SUDO_USER") && getenv("SUDO_UID") && getenv("SUDO_GID"); // NOLINT(concurrency-mt-unsafe)
return geteuid() == 0 && getenv("SUDO_USER") && getenv("SUDO_UID") && getenv("SUDO_GID"); // NOLINT(concurrency-mt-unsafe)
}
/// Read data about files and decomrpess them.
@ -423,6 +423,13 @@ int main(int/* argc*/, char* argv[])
else
name = file_path;
struct stat input_info;
if (0 != stat(self, &input_info))
{
perror("stat");
return 1;
}
#if !defined(OS_DARWIN) && !defined(OS_FREEBSD)
/// get inode of this executable
uint64_t inode = getInode(self);
@ -450,13 +457,6 @@ int main(int/* argc*/, char* argv[])
return 1;
}
struct stat input_info;
if (0 != stat(self, &input_info))
{
perror("stat");
return 1;
}
/// inconsistency in WSL1 Ubuntu - inode reported in /proc/self/maps is a 64bit to
/// 32bit conversion of input_info.st_ino
if (input_info.st_ino & 0xFFFFFFFF00000000 && !(inode & 0xFFFFFFFF00000000))