summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Guenthe <guenther@cvs.openbsd.org>2011-06-18 02:36:23 +0000
committerPhilip Guenthe <guenther@cvs.openbsd.org>2011-06-18 02:36:23 +0000
commit5aecd6b7179a0266aa846bfce2807732b91b3723 (patch)
tree5c65698993e6666e502216aa7f30db40798f345d
parent4e663c403dbf7f6cf12b35edc126dfb09df977e6 (diff)
Warn and stop processing if the format string ends with an backslash.
From Andres Perera (andres.p at zoho.com), ok otto@, millert@
-rw-r--r--usr.bin/printf/printf.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/usr.bin/printf/printf.c b/usr.bin/printf/printf.c
index 311eaf8f906..7973018ae94 100644
--- a/usr.bin/printf/printf.c
+++ b/usr.bin/printf/printf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: printf.c,v 1.17 2009/10/27 23:59:41 deraadt Exp $ */
+/* $OpenBSD: printf.c,v 1.18 2011/06/18 02:36:22 guenther Exp $ */
/*
* Copyright (c) 1989 The Regents of the University of California.
@@ -351,6 +351,11 @@ print_escape(const char *str)
putchar('\v');
break;
+ case '\0':
+ warnx("null escape sequence");
+ rval = 1;
+ return 0;
+
default:
putchar(*str);
warnx("unknown escape sequence `\\%c'", *str);