From 3906e60abcf3b3abbc9fbfc8cc7791eeec20ad3a Mon Sep 17 00:00:00 2001 From: Cameron Nemo Date: Sat, 1 Dec 2018 23:46:56 -0800 Subject: [PATCH] lxc: fix lxc-usernsexec --- srcpkgs/lxc/patches/lxc-usernsexec.patch | 83 ++++++++++++++++++++++++ srcpkgs/lxc/template | 2 +- 2 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 srcpkgs/lxc/patches/lxc-usernsexec.patch diff --git a/srcpkgs/lxc/patches/lxc-usernsexec.patch b/srcpkgs/lxc/patches/lxc-usernsexec.patch new file mode 100644 index 00000000000..666d87c68ce --- /dev/null +++ b/srcpkgs/lxc/patches/lxc-usernsexec.patch @@ -0,0 +1,83 @@ +commit c14ea11dccbfa80021a9b169b94bd86e8b359611 +Author: Cameron Nemo +Date: Wed Nov 28 19:42:29 2018 -0800 + + lxc-usernsexec: fix default map functionality + + * Place NULL bytes at the end of strings so that + lxc_safe_ulong() can parse them correctly + + * Only free the newly created id_map on error, + to avoid passing garbage to lxc_map_ids() + + Signed-off-by: Cameron Nemo + +diff --git src/lxc/cmd/lxc_usernsexec.c src/lxc/cmd/lxc_usernsexec.c +index 10557dd5..ab0dffcf 100644 +--- src/lxc/cmd/lxc_usernsexec.c ++++ src/lxc/cmd/lxc_usernsexec.c +@@ -200,6 +200,7 @@ static int read_default_map(char *fnam, int which, char *user) + { + size_t len; + char *p1, *p2; ++ unsigned long ul1, ul2; + FILE *fin; + int ret = -1; + size_t sz = 0; +@@ -224,37 +225,42 @@ static int read_default_map(char *fnam, int which, char *user) + if (!p2) + continue; + +- newmap = malloc(sizeof(*newmap)); +- if (!newmap) +- goto on_error; ++ line[strlen(line) - 1] = '\0'; ++ *p2 = '\0'; + +- ret = lxc_safe_ulong(p1 + 1, &newmap->hostid); ++ ret = lxc_safe_ulong(p1 + 1, &ul1); + if (ret < 0) +- goto on_error; ++ break; + +- ret = lxc_safe_ulong(p2 + 1, &newmap->range); ++ ret = lxc_safe_ulong(p2 + 1, &ul2); + if (ret < 0) +- goto on_error; ++ break; ++ ++ ret = -1; ++ newmap = malloc(sizeof(*newmap)); ++ if (!newmap) ++ break; + + newmap->nsid = 0; + newmap->idtype = which; ++ newmap->hostid = ul1; ++ newmap->range = ul2; + +- ret = -1; + tmp = malloc(sizeof(*tmp)); +- if (!tmp) +- goto on_error; ++ if (!tmp) { ++ free(newmap); ++ break; ++ } + + tmp->elem = newmap; + lxc_list_add_tail(&active_map, tmp); ++ ++ ret = 0; + break; + } + +- ret = 0; +- +-on_error: + fclose(fin); + free(line); +- free(newmap); + + return ret; + } diff --git a/srcpkgs/lxc/template b/srcpkgs/lxc/template index 88bb8bad2b0..2396c31f020 100644 --- a/srcpkgs/lxc/template +++ b/srcpkgs/lxc/template @@ -3,7 +3,7 @@ _desc="Linux Containers" pkgname=lxc version=3.0.3 -revision=1 +revision=2 build_style=gnu-configure configure_args="--enable-doc --enable-seccomp --enable-capabilities --enable-apparmor --with-distro=none