From 6a0d5aaaa236d05f789620d42232d87c33f15713 Mon Sep 17 00:00:00 2001 From: Reiner Herrmann Date: Thu, 11 Jul 2019 21:39:55 +0200 Subject: rename some variables so they don't shadow others with same name via lgtm.com --- src/firejail/fs_dev.c | 4 ++-- src/firejail/fs_home.c | 10 +++++----- src/firejail/sbox.c | 18 +++++++++--------- src/libtrace/libtrace.c | 30 +++++++++++++++--------------- 4 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/firejail/fs_dev.c b/src/firejail/fs_dev.c index bd036908a..d807f527d 100644 --- a/src/firejail/fs_dev.c +++ b/src/firejail/fs_dev.c @@ -137,8 +137,8 @@ static void deventry_mount(void) { } static void create_char_dev(const char *path, mode_t mode, int major, int minor) { - dev_t dev = makedev(major, minor); - if (mknod(path, S_IFCHR | mode, dev) == -1) + dev_t device = makedev(major, minor); + if (mknod(path, S_IFCHR | mode, device) == -1) goto errexit; if (chmod(path, mode) < 0) goto errexit; diff --git a/src/firejail/fs_home.c b/src/firejail/fs_home.c index 69ad5e2c8..01a807883 100644 --- a/src/firejail/fs_home.c +++ b/src/firejail/fs_home.c @@ -482,14 +482,14 @@ static void duplicate(char *name) { } else if (S_ISDIR(s.st_mode)) { // create the directory in RUN_HOME_DIR - char *name; + char *path; char *ptr = strrchr(fname, '/'); ptr++; - if (asprintf(&name, "%s/%s", RUN_HOME_DIR, ptr) == -1) + if (asprintf(&path, "%s/%s", RUN_HOME_DIR, ptr) == -1) errExit("asprintf"); - mkdir_attr(name, 0755, getuid(), getgid()); - sbox_run(SBOX_USER| SBOX_CAPS_NONE | SBOX_SECCOMP, 3, PATH_FCOPY, fname, name); - free(name); + mkdir_attr(path, 0755, getuid(), getgid()); + sbox_run(SBOX_USER| SBOX_CAPS_NONE | SBOX_SECCOMP, 3, PATH_FCOPY, fname, path); + free(path); } else sbox_run(SBOX_USER| SBOX_CAPS_NONE | SBOX_SECCOMP, 3, PATH_FCOPY, fname, RUN_HOME_DIR); diff --git a/src/firejail/sbox.c b/src/firejail/sbox.c index f387d25fa..a41e32569 100644 --- a/src/firejail/sbox.c +++ b/src/firejail/sbox.c @@ -104,7 +104,7 @@ static struct sock_fprog prog = { .filter = filter, }; -int sbox_run(unsigned filter, int num, ...) { +int sbox_run(unsigned filtermask, int num, ...) { EUID_ROOT(); int i; @@ -148,7 +148,7 @@ int sbox_run(unsigned filter, int num, ...) { if (arg_debug) // --debug is passed as an environment variable setenv("FIREJAIL_DEBUG", "yes", 1); - if (filter & SBOX_STDIN_FROM_FILE) { + if (filtermask & SBOX_STDIN_FROM_FILE) { int fd; if((fd = open(SBOX_STDIN_FILE, O_RDONLY)) == -1) { fprintf(stderr,"Error: cannot open %s\n", SBOX_STDIN_FILE); @@ -157,7 +157,7 @@ int sbox_run(unsigned filter, int num, ...) { dup2(fd,STDIN_FILENO); close(fd); } - else if ((filter & SBOX_ALLOW_STDIN) == 0) { + else if ((filtermask & SBOX_ALLOW_STDIN) == 0) { int fd = open("/dev/null",O_RDWR, 0); if (fd != -1) { dup2(fd, STDIN_FILENO); @@ -175,17 +175,17 @@ int sbox_run(unsigned filter, int num, ...) { umask(027); // apply filters - if (filter & SBOX_CAPS_NONE) { + if (filtermask & SBOX_CAPS_NONE) { caps_drop_all(); } - else if (filter & SBOX_CAPS_NETWORK) { + else if (filtermask & SBOX_CAPS_NETWORK) { #ifndef HAVE_GCOV // the following filter will prevent GCOV from saving info in .gcda files uint64_t set = ((uint64_t) 1) << CAP_NET_ADMIN; set |= ((uint64_t) 1) << CAP_NET_RAW; caps_set(set); #endif } - else if (filter & SBOX_CAPS_HIDEPID) { + else if (filtermask & SBOX_CAPS_HIDEPID) { #ifndef HAVE_GCOV // the following filter will prevent GCOV from saving info in .gcda files uint64_t set = ((uint64_t) 1) << CAP_SYS_PTRACE; set |= ((uint64_t) 1) << CAP_SYS_PACCT; @@ -193,7 +193,7 @@ int sbox_run(unsigned filter, int num, ...) { #endif } - if (filter & SBOX_SECCOMP) { + if (filtermask & SBOX_SECCOMP) { if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0)) { perror("prctl(NO_NEW_PRIVS)"); } @@ -202,14 +202,14 @@ int sbox_run(unsigned filter, int num, ...) { } } - if (filter & SBOX_ROOT) { + if (filtermask & SBOX_ROOT) { // elevate privileges in order to get grsecurity working if (setreuid(0, 0)) errExit("setreuid"); if (setregid(0, 0)) errExit("setregid"); } - else if (filter & SBOX_USER) + else if (filtermask & SBOX_USER) drop_privs(1); if (arg[0]) // get rid of scan-build warning diff --git a/src/libtrace/libtrace.c b/src/libtrace/libtrace.c index 1cab1ed3c..60fdb5470 100644 --- a/src/libtrace/libtrace.c +++ b/src/libtrace/libtrace.c @@ -402,50 +402,50 @@ int rmdir(const char *pathname) { } // stat -typedef int (*orig_stat_t)(const char *pathname, struct stat *buf); +typedef int (*orig_stat_t)(const char *pathname, struct stat *statbuf); static orig_stat_t orig_stat = NULL; -int stat(const char *pathname, struct stat *buf) { +int stat(const char *pathname, struct stat *statbuf) { if (!orig_stat) orig_stat = (orig_stat_t)dlsym(RTLD_NEXT, "stat"); - int rv = orig_stat(pathname, buf); + int rv = orig_stat(pathname, statbuf); fprintf(ftty, "%u:%s:stat %s:%d\n", mypid, myname, pathname, rv); return rv; } #ifdef __GLIBC__ -typedef int (*orig_stat64_t)(const char *pathname, struct stat64 *buf); +typedef int (*orig_stat64_t)(const char *pathname, struct stat64 *statbuf); static orig_stat64_t orig_stat64 = NULL; -int stat64(const char *pathname, struct stat64 *buf) { +int stat64(const char *pathname, struct stat64 *statbuf) { if (!orig_stat64) orig_stat64 = (orig_stat64_t)dlsym(RTLD_NEXT, "stat64"); - int rv = orig_stat64(pathname, buf); + int rv = orig_stat64(pathname, statbuf); fprintf(ftty, "%u:%s:stat64 %s:%d\n", mypid, myname, pathname, rv); return rv; } #endif /* __GLIBC__ */ // lstat -typedef int (*orig_lstat_t)(const char *pathname, struct stat *buf); +typedef int (*orig_lstat_t)(const char *pathname, struct stat *statbuf); static orig_lstat_t orig_lstat = NULL; -int lstat(const char *pathname, struct stat *buf) { +int lstat(const char *pathname, struct stat *statbuf) { if (!orig_lstat) orig_lstat = (orig_lstat_t)dlsym(RTLD_NEXT, "lstat"); - int rv = orig_lstat(pathname, buf); + int rv = orig_lstat(pathname, statbuf); fprintf(ftty, "%u:%s:lstat %s:%d\n", mypid, myname, pathname, rv); return rv; } #ifdef __GLIBC__ -typedef int (*orig_lstat64_t)(const char *pathname, struct stat64 *buf); +typedef int (*orig_lstat64_t)(const char *pathname, struct stat64 *statbuf); static orig_lstat64_t orig_lstat64 = NULL; -int lstat64(const char *pathname, struct stat64 *buf) { +int lstat64(const char *pathname, struct stat64 *statbuf) { if (!orig_lstat64) orig_lstat64 = (orig_lstat64_t)dlsym(RTLD_NEXT, "lstat64"); - int rv = orig_lstat64(pathname, buf); + int rv = orig_lstat64(pathname, statbuf); fprintf(ftty, "%u:%s:lstat64 %s:%d\n", mypid, myname, pathname, rv); return rv; } @@ -492,13 +492,13 @@ int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen) { // socket typedef int (*orig_socket_t)(int domain, int type, int protocol); static orig_socket_t orig_socket = NULL; -static char buf[1024]; +static char socketbuf[1024]; int socket(int domain, int type, int protocol) { if (!orig_socket) orig_socket = (orig_socket_t)dlsym(RTLD_NEXT, "socket"); int rv = orig_socket(domain, type, protocol); - char *ptr = buf; + char *ptr = socketbuf; ptr += sprintf(ptr, "%u:%s:socket ", mypid, myname); char *str = translate(socket_domain, domain); if (str == NULL) @@ -529,7 +529,7 @@ int socket(int domain, int type, int protocol) { sprintf(ptr, "%s", str); } - fprintf(ftty, "%s:%d\n", buf, rv); + fprintf(ftty, "%s:%d\n", socketbuf, rv); return rv; } -- cgit v1.2.3-54-g00ecf