From 9163a33b13c907943f78f14f988d03575a6ef792 Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Wed, 16 Aug 2017 00:34:23 +0200 Subject: [PATCH] bdev: enable building with gcc7 We shouldn't ignore this anyway. Signed-off-by: Christian Brauner --- src/lxc/bdev.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lxc/bdev.c b/src/lxc/bdev.c index 1f1fd66a6..59eda7e40 100644 --- a/src/lxc/bdev.c +++ b/src/lxc/bdev.c @@ -1917,6 +1917,8 @@ static int find_free_loopdev_no_control(int *retfd, char *namep) } while ((direntp = readdir(dir))) { + int ret; + if (!direntp) break; if (strncmp(direntp->d_name, "loop", 4) != 0) @@ -1930,7 +1932,11 @@ static int find_free_loopdev_no_control(int *retfd, char *namep) continue; } // We can use this fd - snprintf(namep, 100, "/dev/%s", direntp->d_name); + ret = snprintf(namep, 100, "/dev/%s", direntp->d_name); + if (ret < 0 || ret >= 100) { + close(fd); + fd = -1; + } break; } closedir(dir); -- 2.47.2