summaryrefslogtreecommitdiff
path: root/usr.bin/mktemp
diff options
context:
space:
mode:
authorLandry Breuil <landry@cvs.openbsd.org>2013-08-06 21:56:52 +0000
committerLandry Breuil <landry@cvs.openbsd.org>2013-08-06 21:56:52 +0000
commite84fad8cc7ee83c632565fdf0343c3de1e3faee1 (patch)
treee7d811df0bea2b5588ab51fd0ba3e2944878a421 /usr.bin/mktemp
parent9c1c78af7fbb6cacf7a0d434f54e494025df32b9 (diff)
Move the check for template length added in r1.16 outside the !tflag
block so that the friendly error message is also shown in the -t case instead of EINVAL. ok millert@ deraadt@
Diffstat (limited to 'usr.bin/mktemp')
-rw-r--r--usr.bin/mktemp/mktemp.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/usr.bin/mktemp/mktemp.c b/usr.bin/mktemp/mktemp.c
index 9833e3ef549..8e0ab148aca 100644
--- a/usr.bin/mktemp/mktemp.c
+++ b/usr.bin/mktemp/mktemp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mktemp.c,v 1.19 2013/03/14 15:44:15 millert Exp $ */
+/* $OpenBSD: mktemp.c,v 1.20 2013/08/06 21:56:51 landry Exp $ */
/*
* Copyright (c) 1996, 1997, 2001-2003, 2013
@@ -73,6 +73,11 @@ main(int argc, char *argv[])
usage();
}
+ len = strlen(template);
+ if (len < 6 || strcmp(&template[len - 6], "XXXXXX")) {
+ fatalx("insufficient number of Xs in template `%s'",
+ template);
+ }
if (tflag) {
if (strchr(template, '/')) {
fatalx("template must not contain directory "
@@ -88,14 +93,9 @@ main(int argc, char *argv[])
if (asprintf(&tempfile, "%.*s/%s", (int)len, prefix, template) < 0)
tempfile = NULL;
- } else {
- len = strlen(template);
- if (len < 6 || strcmp(&template[len - 6], "XXXXXX")) {
- fatalx("insufficient number of Xs in template `%s'",
- template);
- }
+ } else
tempfile = strdup(template);
- }
+
if (tempfile == NULL)
fatalx("cannot allocate memory");