summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/test_ioctl.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/tests/test_ioctl.c b/tests/test_ioctl.c
index 077e553..1f31c2e 100644
--- a/tests/test_ioctl.c
+++ b/tests/test_ioctl.c
@@ -33,6 +33,7 @@ static void teardown(void **state)
{
char remove_cmd[256] = {0};
const char *swrap_dir = getenv("SOCKET_WRAPPER_DIR");
+ char *s;
int rc;
(void) state; /* unused */
@@ -40,7 +41,11 @@ static void teardown(void **state)
if (swrap_dir == NULL) {
return;
}
- snprintf(remove_cmd, sizeof(remove_cmd), "rm -rf %s", swrap_dir);
+
+ /* Do not use a tainted string in snprintf */
+ s = strdup(swrap_dir);
+ snprintf(remove_cmd, sizeof(remove_cmd), "rm -rf %s", s);
+ free(s);
rc = system(remove_cmd);
if (rc < 0) {