]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
cmd: use safe number parsers in lxc-usernsexec
authorChristian Brauner <christian.brauner@ubuntu.com>
Sun, 19 Aug 2018 17:41:00 +0000 (19:41 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Sun, 19 Aug 2018 18:27:45 +0000 (20:27 +0200)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/cmd/lxc_usernsexec.c

index a2c51800569eed6db22265862407264bb55eede5..4909a93244ba3b69b05a3e56e971fb1ccb6b6d5c 100644 (file)
@@ -196,6 +196,7 @@ static int parse_map(char *map)
  */
 static int read_default_map(char *fnam, int which, char *user)
 {
+       int ret;
        size_t len;
        char *p1, *p2;
        FILE *fin;
@@ -228,8 +229,20 @@ static int read_default_map(char *fnam, int which, char *user)
                        return -1;
                }
 
-               newmap->hostid = atol(p1 + 1);
-               newmap->range = atol(p2 + 1);
+               ret = lxc_safe_ulong(p1 + 1, &newmap->hostid);
+               if (ret < 0) {
+                       fclose(fin);
+                       free(line);
+                       return -1;
+               }
+
+               ret = lxc_safe_ulong(p2 + 1, &newmap->range);
+               if (ret < 0) {
+                       fclose(fin);
+                       free(line);
+                       return -1;
+               }
+
                newmap->nsid = 0;
                newmap->idtype = which;