From 4e22add64497a1edef18854efc52ca0b682c0bcb Mon Sep 17 00:00:00 2001 From: netblue30 Date: Sun, 29 Nov 2015 13:02:48 -0500 Subject: [PATCH] llvm scan --- Makefile.in | 6 ++++++ src/firejail/fs_logger.c | 1 + src/firejail/fs_whitelist.c | 4 +++- src/firejail/network.c | 4 ++-- src/libtrace/libtrace.c | 4 ++-- todo | 2 +- 6 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Makefile.in b/Makefile.in index 083a8853894..c14ec5cdc29 100644 --- a/Makefile.in +++ b/Makefile.in @@ -184,3 +184,9 @@ deb: dist extras: all $(MAKE) -C extras/firetools +cppcheck: clean + cppcheck --force . + +scan-build: clean + scan-build make + diff --git a/src/firejail/fs_logger.c b/src/firejail/fs_logger.c index f735b1489b3..9f742c5bddf 100644 --- a/src/firejail/fs_logger.c +++ b/src/firejail/fs_logger.c @@ -90,6 +90,7 @@ void fs_logger_print(void) { } int rv = chown(RUN_FSLOGGER_FILE, getuid(), getgid()); + (void) rv; // best effort! rv = chmod(RUN_FSLOGGER_FILE, 0600); (void) rv; // best effort! diff --git a/src/firejail/fs_whitelist.c b/src/firejail/fs_whitelist.c index e0187981b2a..a584cb69d50 100644 --- a/src/firejail/fs_whitelist.c +++ b/src/firejail/fs_whitelist.c @@ -390,8 +390,10 @@ void fs_whitelist(void) { // mark symbolic links if (is_link(new_name)) entry->link = new_name; - else + else { free(new_name); + new_name = NULL; + } // change file name in entry->data if (strcmp(fname, entry->data + 10) != 0) { diff --git a/src/firejail/network.c b/src/firejail/network.c index 461946d830e..5f7a84a1e6a 100644 --- a/src/firejail/network.c +++ b/src/firejail/network.c @@ -138,8 +138,8 @@ void net_set_mtu(const char *ifname, int mtu) { ifr.ifr_addr.sa_family = AF_INET; strncpy(ifr.ifr_name, ifname, IFNAMSIZ); ifr.ifr_mtu = mtu; - if (ioctl(s, SIOCSIFMTU, (caddr_t)&ifr) == 0) - mtu = ifr.ifr_mtu; + if (ioctl(s, SIOCSIFMTU, (caddr_t)&ifr) != 0) + fprintf(stderr, "Warning: cannot set mtu for interface %s\n", ifname); close(s); } diff --git a/src/libtrace/libtrace.c b/src/libtrace/libtrace.c index b763213f6b3..44f0cc4d0e8 100644 --- a/src/libtrace/libtrace.c +++ b/src/libtrace/libtrace.c @@ -490,9 +490,9 @@ int socket(int domain, int type, int protocol) { str = translate(socket_protocol, protocol); if (str == NULL) - ptr += sprintf(ptr, "%d", protocol); + sprintf(ptr, "%d", protocol); else - ptr += sprintf(ptr, "%s", str); + sprintf(ptr, "%s", str); printf("%s\n", buf); return rv; diff --git a/todo b/todo index 0c77383957a..863a34fe45d 100644 --- a/todo +++ b/todo @@ -154,4 +154,4 @@ I was messing around with my fstab, and found out that firejail can't have /usr/ /dev/mapper/asdf-usr--local /usr/local ext4 defaults,nosuid,noatime,ro 0 2 /dev/mapper/asdf-usr--sbin /usr/sbin ext4 defaults,nosuid,,noatime,ro 0 2 /dev/mapper/asdf-var /var ext4 discard,noatime,nodev,nosuid 0 2 -tmpfs /tmp tmpfs noatime,nosuid,nodev,size=2G 0 1 \ No newline at end of file +tmpfs /tmp tmpfs noatime,nosuid,nodev,size=2G 0 1