diff options
author | Andreas Schneider <asn@samba.org> | 2014-05-28 09:46:57 +0200 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2014-06-01 10:03:05 +0200 |
commit | b357525a2958e394fceb8c7b6165b572e944e8f2 (patch) | |
tree | f07f839afdfa0247f0babfe45dea43b3a2e44657 | |
parent | 3029067b21775c1f6fec43e0b03712defa69e9a6 (diff) | |
download | socket_wrapper-b357525a2958e394fceb8c7b6165b572e944e8f2.tar.gz socket_wrapper-b357525a2958e394fceb8c7b6165b572e944e8f2.tar.xz socket_wrapper-b357525a2958e394fceb8c7b6165b572e944e8f2.zip |
tests: Avoid using getenv() to retrieve the path.
CID 17221
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
-rw-r--r-- | tests/test_ioctl.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/tests/test_ioctl.c b/tests/test_ioctl.c index 6333720..47ef838 100644 --- a/tests/test_ioctl.c +++ b/tests/test_ioctl.c @@ -11,6 +11,7 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> +#include <limits.h> #include <unistd.h> static void setup(void **state) @@ -25,24 +26,23 @@ static void setup(void **state) p = mkdtemp(test_tmpdir); assert_non_null(p); + *state = strdup(p); setenv("SOCKET_WRAPPER_DIR", p, 1); setenv("SOCKET_WRAPPER_DEFAULT_IFACE", "11", 1); } static void teardown(void **state) { - char remove_cmd[1024] = {0}; - const char *swrap_dir = getenv("SOCKET_WRAPPER_DIR"); + char remove_cmd[PATH_MAX] = {0}; + char *s = (char *)*state; int rc; - (void) state; /* unused */ - - if (swrap_dir == NULL) { + if (s == NULL) { return; } - strcpy(remove_cmd, "rm -rf "); - strncpy(remove_cmd + 8, swrap_dir, sizeof(remove_cmd) - 9); + snprintf(remove_cmd, sizeof(remove_cmd), "rm -rf %s", s); + free(s); rc = system(remove_cmd); if (rc < 0) { |