[lxc-devel] [lxc/master] coverity
brauner on Github
lxc-bot at linuxcontainers.org
Fri Jun 15 11:39:16 UTC 2018
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 364 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180615/0dba5739/attachment.bin>
-------------- next part --------------
From df35b5abefdb5479be9e7f72e3786189b96ed0fd Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Fri, 15 Jun 2018 13:34:04 +0200
Subject: [PATCH 1/4] coverity: #1425748
Time of check time of use
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
src/lxc/conf.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/src/lxc/conf.c b/src/lxc/conf.c
index 938762551..6d5451058 100644
--- a/src/lxc/conf.c
+++ b/src/lxc/conf.c
@@ -1541,14 +1541,11 @@ static int lxc_setup_devpts(struct lxc_conf *conf)
if (ret < 0 || (size_t)ret >= sizeof(devpts_mntopts))
return -1;
- /* Unmount old devpts instance. */
- ret = access("/dev/pts/ptmx", F_OK);
- if (!ret) {
- ret = umount("/dev/pts");
- if (ret < 0) {
- SYSERROR("Failed to unmount old devpts instance");
- return -1;
- }
+ ret = umount2("/dev/pts", MNT_DETACH);
+ if (ret < 0) {
+ WARN("%s - Failed to unmount old devpts instance", strerror(errno));
+ return -1;
+ } else {
DEBUG("Unmounted old devpts instance");
}
From d036b1a1b7efd6b2536922af88d96c9e913431d3 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Fri, 15 Jun 2018 13:35:09 +0200
Subject: [PATCH 2/4] coverity: #1425789
Unchecked return value from library
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
src/lxc/lxccontainer.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c
index 4dd12dda3..f2a29acf8 100644
--- a/src/lxc/lxccontainer.c
+++ b/src/lxc/lxccontainer.c
@@ -2625,7 +2625,10 @@ static bool mod_rdep(struct lxc_container *c0, struct lxc_container *c, bool inc
n = fscanf(f1, "%d", &v);
fclose(f1);
if (n == 1 && v == 0) {
- remove(path);
+ ret = remove(path);
+ if (ret < 0)
+ ERROR("%s - Failed to remove \"%s\"",
+ strerror(errno), path);
n = 0;
}
}
From f0b12c1fdcf27d4c94e79e28acc49c1aff50a581 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Fri, 15 Jun 2018 13:36:37 +0200
Subject: [PATCH 3/4] coverity: #1425855
String not null terminated
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
src/lxc/tools/lxc_info.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/lxc/tools/lxc_info.c b/src/lxc/tools/lxc_info.c
index 16d60f48d..09889e31e 100644
--- a/src/lxc/tools/lxc_info.c
+++ b/src/lxc/tools/lxc_info.c
@@ -178,6 +178,7 @@ static void print_net_stats(struct lxc_container *c)
rc = lxc_read_from_file(path, buf, sizeof(buf));
if (rc > 0) {
+ buf[rc - 1] = '\0';
str_chomp(buf);
rx_bytes = str_size_humanize(buf, sizeof(buf));
printf("%-15s %s\n", " TX bytes:", buf);
@@ -190,6 +191,7 @@ static void print_net_stats(struct lxc_container *c)
rc = lxc_read_from_file(path, buf, sizeof(buf));
if (rc > 0) {
+ buf[rc - 1] = '\0';
str_chomp(buf);
tx_bytes = str_size_humanize(buf, sizeof(buf));
printf("%-15s %s\n", " RX bytes:", buf);
From 5750abfad0a6eaa26b52ff0c1636f01bdd8e5d79 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Fri, 15 Jun 2018 13:37:47 +0200
Subject: [PATCH 4/4] coverity: #1437027
Read from pointer after free
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
src/lxc/tools/lxc_ls.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/lxc/tools/lxc_ls.c b/src/lxc/tools/lxc_ls.c
index a192eb0d5..d6806fbf3 100644
--- a/src/lxc/tools/lxc_ls.c
+++ b/src/lxc/tools/lxc_ls.c
@@ -819,8 +819,8 @@ static void ls_print_fancy_format(struct ls *l, struct lengths *lht,
strcasecmp(*s, "GROUPS") && strcasecmp(*s, "INTERFACE") &&
strcasecmp(*s, "IPV4") && strcasecmp(*s, "IPV6") &&
strcasecmp(*s, "UNPRIVILEGED")) {
- lxc_free_array((void **)tmp, free);
fprintf(stderr, "Invalid key: %s\n", *s);
+ lxc_free_array((void **)tmp, free);
return;
}
}
More information about the lxc-devel
mailing list