]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
bdev: enable building with gcc7 1749/head
authorChristian Brauner <christian.brauner@ubuntu.com>
Tue, 15 Aug 2017 22:34:23 +0000 (00:34 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Tue, 15 Aug 2017 22:45:14 +0000 (00:45 +0200)
We shouldn't ignore this anyway.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/bdev.c

index 1f1fd66a61bc53d8734221ff0c889f7d444b1094..59eda7e40c90acec024fb509dad200b47e912daf 100644 (file)
@@ -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);