diff options
| author | kre <kre@NetBSD.org> | 2018-07-03 01:54:42 +0000 |
|---|---|---|
| committer | kre <kre@NetBSD.org> | 2018-07-03 01:54:42 +0000 |
| commit | 130da49dc0ea73a4b13f78f27488343dff6b868f (patch) | |
| tree | 5bbc489758090fc3cd4153e6babc7ba3096533de /usr.bin/printf/printf.c | |
| parent | 9c3f283eae7bf9b1db04827aa56f4091f0427db3 (diff) | |
From leot@ on tech-userlevel:
Avoid running off into oblivion when a format string,
or arg to a %b conversion ends in an unescaped backslash.
Patch from Leo slightly modified by me.
Diffstat (limited to 'usr.bin/printf/printf.c')
| -rw-r--r-- | usr.bin/printf/printf.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/usr.bin/printf/printf.c b/usr.bin/printf/printf.c index 231109d398f..a65e71c10c9 100644 --- a/usr.bin/printf/printf.c +++ b/usr.bin/printf/printf.c @@ -1,4 +1,4 @@ -/* $NetBSD: printf.c,v 1.37 2015/06/16 22:54:10 christos Exp $ */ +/* $NetBSD: printf.c,v 1.38 2018/07/03 01:54:42 kre Exp $ */ /* * Copyright (c) 1989, 1993 @@ -41,7 +41,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1993\ #if 0 static char sccsid[] = "@(#)printf.c 8.2 (Berkeley) 3/22/95"; #else -__RCSID("$NetBSD: printf.c,v 1.37 2015/06/16 22:54:10 christos Exp $"); +__RCSID("$NetBSD: printf.c,v 1.38 2018/07/03 01:54:42 kre Exp $"); #endif #endif /* not lint */ @@ -433,6 +433,13 @@ conv_escape(char *str, char *conv_ch) ch = *str++; switch (ch) { + case '\0': + warnx("incomplete escape sequence"); + rval = 1; + value = '\\'; + --str; + break; + case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': num_buf[0] = ch; |
