From 30620afb6c6c75e14ebd9de876114f88a83f0355 Mon Sep 17 00:00:00 2001 From: sin Date: Fri, 24 Jan 2014 16:17:39 +0000 Subject: [PATCH] Check return value of snprintf in mktemp(1) --- mktemp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mktemp.c b/mktemp.c index 8416a01..4988e58 100644 --- a/mktemp.c +++ b/mktemp.c @@ -42,7 +42,8 @@ main(int argc, char *argv[]) if ((p = getenv("TMPDIR"))) tmpdir = p; - snprintf(tmppath, sizeof(tmppath), "%s/%s", tmpdir, template); + if (snprintf(tmppath, sizeof(tmppath), "%s/%s", tmpdir, template) >= sizeof(tmppath)) + eprintf(EXIT_FAILURE, "path too long\n"); if (dflag) { if (!mkdtemp(tmppath)) { if (!qflag)