sbase

suckless unix tools
git clone git://git.2f30.org/sbase
Log | Files | Refs | README | LICENSE

commit 30620afb6c6c75e14ebd9de876114f88a83f0355
parent 5be9c21ce43b028fb27b51cb7a7c02e05736f002
Author: sin <sin@2f30.org>
Date:   Fri, 24 Jan 2014 16:17:39 +0000

Check return value of snprintf in mktemp(1)

Diffstat:
Mmktemp.c | 3++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git 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)