From 1065bfa117fb012eb7c4eb17b5118f6e2eb0a663 Mon Sep 17 00:00:00 2001 From: Reiner Herrmann Date: Sun, 15 Nov 2015 11:09:32 +0100 Subject: Fix warnings by clang-analyzer (scan-build) --- src/firejail/fs_whitelist.c | 4 ++-- src/firejail/util.c | 2 +- src/lib/libnetlink.c | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/firejail/fs_whitelist.c b/src/firejail/fs_whitelist.c index 073e247dc..2751a8c71 100644 --- a/src/firejail/fs_whitelist.c +++ b/src/firejail/fs_whitelist.c @@ -61,7 +61,7 @@ static void whitelist_path(ProfileEntry *entry) { char *path = entry->data + 10; assert(path); const char *fname; - char *wfile; + char *wfile = NULL; if (entry->home_dir) { fname = path + strlen(cfg.homedir); @@ -86,7 +86,7 @@ static void whitelist_path(ProfileEntry *entry) { // check if the file exists struct stat s; - if (stat(wfile, &s) == 0) { + if (wfile && stat(wfile, &s) == 0) { if (arg_debug) printf("Whitelisting %s\n", path); } diff --git a/src/firejail/util.c b/src/firejail/util.c index d2e6c2799..89d0697fd 100644 --- a/src/firejail/util.c +++ b/src/firejail/util.c @@ -258,7 +258,7 @@ char *line_remove_spaces(const char *buf) { } // strip last blank character if any - if (*(ptr2 - 1) == ' ') + if (ptr2 > rv && *(ptr2 - 1) == ' ') --ptr2; *ptr2 = '\0'; // if (arg_debug) diff --git a/src/lib/libnetlink.c b/src/lib/libnetlink.c index fddbc209d..07457eefe 100644 --- a/src/lib/libnetlink.c +++ b/src/lib/libnetlink.c @@ -626,7 +626,8 @@ printf("\tdata length: %d\n", alen); rta = NLMSG_TAIL(n); rta->rta_type = type; rta->rta_len = len; - memcpy(RTA_DATA(rta), data, alen); + if (data) + memcpy(RTA_DATA(rta), data, alen); n->nlmsg_len = NLMSG_ALIGN(n->nlmsg_len) + RTA_ALIGN(len); return 0; } -- cgit v1.2.3-54-g00ecf