Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/printf From leot@ on tech-userlevel:



details:   https://anonhg.NetBSD.org/src/rev/024c64956afa
branches:  trunk
changeset: 320360:024c64956afa
user:      kre <kre%NetBSD.org@localhost>
date:      Tue Jul 03 01:54:42 2018 +0000

description:
>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:

 usr.bin/printf/printf.c |  11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diffs (32 lines):

diff -r ed1a4265bbd1 -r 024c64956afa usr.bin/printf/printf.c
--- a/usr.bin/printf/printf.c   Mon Jul 02 23:54:52 2018 +0000
+++ b/usr.bin/printf/printf.c   Tue Jul 03 01:54:42 2018 +0000
@@ -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 @@
 #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 @@
        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;



Home | Main Index | Thread Index | Old Index