Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/jot Don't coredump if format given via -w doesn't co...



details:   https://anonhg.NetBSD.org/src/rev/6de301b24bce
branches:  trunk
changeset: 504448:6de301b24bce
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Fri Mar 02 21:17:31 2001 +0000

description:
Don't coredump if format given via -w doesn't contain alphanumeric
character; in such case, warn user the format is invalid.

This addresses bin/12316 by Perry E. Metzger.

diffstat:

 usr.bin/jot/jot.c |  10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diffs (38 lines):

diff -r 0e181e7d54ca -r 6de301b24bce usr.bin/jot/jot.c
--- a/usr.bin/jot/jot.c Fri Mar 02 20:36:00 2001 +0000
+++ b/usr.bin/jot/jot.c Fri Mar 02 21:17:31 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: jot.c,v 1.5 1998/12/19 17:06:20 christos Exp $ */
+/*     $NetBSD: jot.c,v 1.6 2001/03/02 21:17:31 jdolecek Exp $ */
 
 /*-
  * Copyright (c) 1993
@@ -43,7 +43,7 @@
 #if 0
 static char sccsid[] = "@(#)jot.c      8.1 (Berkeley) 6/6/93";
 #endif
-__RCSID("$NetBSD: jot.c,v 1.5 1998/12/19 17:06:20 christos Exp $");
+__RCSID("$NetBSD: jot.c,v 1.6 2001/03/02 21:17:31 jdolecek Exp $");
 #endif /* not lint */
 
 /*
@@ -381,8 +381,8 @@
        else if (!*(p+1))
                strcat(format, "%");            /* cannot end in single '%' */
        else {
-               while (!isalpha((unsigned char)*p))
-                       p++;
+               for(; *p && !isalpha((unsigned char)*p); p++)
+                       ;
                switch (*p) {
                case 'f': case 'e': case 'g': case '%':
                        break;
@@ -392,6 +392,8 @@
                /* case 'd': case 'o': case 'x': case 'D': case 'O': case 'X':
                case 'c': case 'u': */
                default:
+                       if (!isalpha(*p))
+                               error("Invalid format '%s'", format);
                        dox = 1;
                        break;
                }



Home | Main Index | Thread Index | Old Index