Source-Changes-HG archive

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

[src/trunk]: src/bin/sh make sure we do not truncate arith expresssion > 10 d...



details:   https://anonhg.NetBSD.org/src/rev/bcbf0a51ecba
branches:  trunk
changeset: 515216:bcbf0a51ecba
user:      itojun <itojun%NetBSD.org@localhost>
date:      Wed Sep 19 06:38:19 2001 +0000

description:
make sure we do not truncate arith expresssion > 10 digits.
freebsd bin/sh/expand.c revision 1.15.  NetBSD PR 13943.

diffstat:

 bin/sh/expand.c |  11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diffs (39 lines):

diff -r 5d1f017550eb -r bcbf0a51ecba bin/sh/expand.c
--- a/bin/sh/expand.c   Wed Sep 19 06:03:59 2001 +0000
+++ b/bin/sh/expand.c   Wed Sep 19 06:38:19 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: expand.c,v 1.51 2001/03/30 17:45:00 mycroft Exp $      */
+/*     $NetBSD: expand.c,v 1.52 2001/09/19 06:38:19 itojun Exp $       */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -41,7 +41,7 @@
 #if 0
 static char sccsid[] = "@(#)expand.c   8.5 (Berkeley) 5/15/95";
 #else
-__RCSID("$NetBSD: expand.c,v 1.51 2001/03/30 17:45:00 mycroft Exp $");
+__RCSID("$NetBSD: expand.c,v 1.52 2001/09/19 06:38:19 itojun Exp $");
 #endif
 #endif /* not lint */
 
@@ -373,7 +373,10 @@
         * have to rescan starting from the beginning since CTLESC
         * characters have to be processed left to right.
         */
-       CHECKSTRSPACE(8, expdest);
+#if INT_MAX / 1000000000 >= 10 || INT_MIN / 1000000000 <= -10
+#error "integers with more than 10 digits are not supported"
+#endif
+       CHECKSTRSPACE(12 - 2, expdest);
        USTPUTC('\0', expdest);
        start = stackblock();
        p = expdest - 1;
@@ -395,7 +398,7 @@
        if (quotes)
                rmescapes(p+2);
        result = arith(p+2);
-       fmtstr(p, 10, "%d", result);
+       fmtstr(p, 12, "%d", result);
 
        while (*p++)
                ;



Home | Main Index | Thread Index | Old Index