From e08543094231b9b209a5f0a48e87520a3083a011 Mon Sep 17 00:00:00 2001 From: Ngie Cooper Date: Sat, 10 Dec 2016 16:22:10 -0800 Subject: [PATCH] Don't overrun `tmpdir` buffer with sprintf If progname is sufficiently large enough, it would overflow the `tmpdir` buffer, causing an illegal memory access Reported by: Coverity CID: 1331594 --- tar/test/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tar/test/main.c b/tar/test/main.c index 6077af5f0..6bc355783 100644 --- a/tar/test/main.c +++ b/tar/test/main.c @@ -2958,8 +2958,8 @@ main(int argc, char **argv) strftime(tmpdir_timestamp, sizeof(tmpdir_timestamp), "%Y-%m-%dT%H.%M.%S", localtime(&now)); - sprintf(tmpdir, "%s/%s.%s-%03d", tmp, progname, - tmpdir_timestamp, i); + snprintf(tmpdir, sizeof(tmpdir), "%s/%s.%s-%03d", tmp, + progname, tmpdir_timestamp, i); if (assertMakeDir(tmpdir,0755)) break; if (i >= 999) { -- 2.47.2