commit 30620afb6c6c75e14ebd9de876114f88a83f0355
Author: sin <[email protected]>
Date:   Fri Jan 24 16:17:39 2014 +0000

    Check return value of snprintf in mktemp(1)

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
");
        if (dflag) {
                if (!mkdtemp(tmppath)) {
                        if (!qflag)


Reply via email to