From 1d7993bd4076bf4b15807fcf340976123817bd0b Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 14 Apr 2014 21:54:17 +0200 Subject: tests: Fix use of tainted string in test_ioctl. CID: #17221 Signed-off-by: Andreas Schneider Reviewed-by: Michael Adam --- tests/test_ioctl.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'tests') 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) { -- cgit