]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
lxc/utils: bugfix freed pointer return value
authorSilvio Fricke <silvio.fricke@gmail.com>
Fri, 14 Nov 2014 19:56:12 +0000 (20:56 +0100)
committerStéphane Graber <stgraber@ubuntu.com>
Tue, 25 Nov 2014 22:14:51 +0000 (17:14 -0500)
We allocate a pointer and save this address in a static variable. After
this we freed this pointer and return.

Here a cuttout of a valgrind report:

[...]
==11568== Invalid read of size 1
==11568==    at 0x4C2D524: strlen (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==11568==    by 0x5961C9B: puts (in /usr/lib/libc-2.20.so)
==11568==    by 0x400890: main (lxc_config.c:73)
==11568==  Address 0x6933e21 is 1 bytes inside a block of size 32 free'd
==11568==    at 0x4C2B200: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==11568==    by 0x4E654F2: lxc_global_config_value (utils.c:415)
==11568==    by 0x4E92177: lxc_get_global_config_item (lxccontainer.c:2287)
==11568==    by 0x400883: main (lxc_config.c:71)
[...]

Signed-off-by: Silvio Fricke <silvio.fricke@gmail.com>
src/lxc/utils.c

index f3f49d31cd2c54460809da441cfcb9b8fd2cce2e..5ef04fc6974a19af9f5e5259071d42b5fc94f02a 100644 (file)
@@ -348,6 +348,7 @@ const char *lxc_global_config_value(const char *option_name)
                                user_lxc_path = copy_global_config_value(p);
                                remove_trailing_slashes(user_lxc_path);
                                values[i] = user_lxc_path;
+                               user_lxc_path = NULL;
                                goto out;
                        }