diff options
| author | Andreas Schneider <asn@samba.org> | 2014-05-27 09:35:00 +0200 |
|---|---|---|
| committer | Andreas Schneider <asn@samba.org> | 2014-05-27 09:51:52 +0200 |
| commit | edaceb0f8fd77cddb78616f3a854accf7175a64b (patch) | |
| tree | 6835d6cd3a4072acf6f5c126df96bff7343ef77f /tests | |
| parent | 43a39c5e288423d1be5b5544d8e13847726d7eda (diff) | |
| download | socket_wrapper-edaceb0f8fd77cddb78616f3a854accf7175a64b.tar.gz socket_wrapper-edaceb0f8fd77cddb78616f3a854accf7175a64b.tar.xz socket_wrapper-edaceb0f8fd77cddb78616f3a854accf7175a64b.zip | |
tests: Fix possible format string attack.
Well, there is really not attack on a test but we want to silence
Coverity :)
CID 17221
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_ioctl.c | 9 |
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) { |
