summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/test_ioctl.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/tests/test_ioctl.c b/tests/test_ioctl.c
index 1f31c2e..6333720 100644
--- a/tests/test_ioctl.c
+++ b/tests/test_ioctl.c
@@ -31,9 +31,8 @@ static void setup(void **state)
static void teardown(void **state)
{
- char remove_cmd[256] = {0};
+ char remove_cmd[1024] = {0};
const char *swrap_dir = getenv("SOCKET_WRAPPER_DIR");
- char *s;
int rc;
(void) state; /* unused */
@@ -42,10 +41,8 @@ static void teardown(void **state)
return;
}
- /* Do not use a tainted string in snprintf */
- s = strdup(swrap_dir);
- snprintf(remove_cmd, sizeof(remove_cmd), "rm -rf %s", s);
- free(s);
+ strcpy(remove_cmd, "rm -rf ");
+ strncpy(remove_cmd + 8, swrap_dir, sizeof(remove_cmd) - 9);
rc = system(remove_cmd);
if (rc < 0) {