Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 28 May 2011 03:18:03 +0000
From:      zy@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r222497 - in soc2011/zy/nvi-iconv/head/usr.bin/nvi: common ex
Message-ID:  <20110528031803.7A27C106564A@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: zy
Date: Sat May 28 03:18:03 2011
New Revision: 222497
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=222497

Log:
  Resolves two number overflow problems based on following facts:
  1. CHAT_T  (unsigned) overflows to 0;
  2. recno_t (unsigned) is set to MAX_REC_NUMBER if strtoul() overflows.

Modified:
  soc2011/zy/nvi-iconv/head/usr.bin/nvi/common/key.c
  soc2011/zy/nvi-iconv/head/usr.bin/nvi/ex/ex_subst.c

Modified: soc2011/zy/nvi-iconv/head/usr.bin/nvi/common/key.c
==============================================================================
--- soc2011/zy/nvi-iconv/head/usr.bin/nvi/common/key.c	Sat May 28 03:13:09 2011	(r222496)
+++ soc2011/zy/nvi-iconv/head/usr.bin/nvi/common/key.c	Sat May 28 03:18:03 2011	(r222497)
@@ -145,7 +145,7 @@
 	}
 
 	/* Find a non-printable character to use as a message separator. */
-	for (ch = 1; ch <= MAX_CHAR_T; ++ch)
+	for (ch = 1; ch != 0; ++ch) /* XXX quit if overflowed */
 		if (!isprint(ch)) {
 			gp->noprint = ch;
 			break;

Modified: soc2011/zy/nvi-iconv/head/usr.bin/nvi/ex/ex_subst.c
==============================================================================
--- soc2011/zy/nvi-iconv/head/usr.bin/nvi/ex/ex_subst.c	Sat May 28 03:13:09 2011	(r222496)
+++ soc2011/zy/nvi-iconv/head/usr.bin/nvi/ex/ex_subst.c	Sat May 28 03:18:03 2011	(r222497)
@@ -418,12 +418,10 @@
 			if (*s == '\0')		/* Loop increment correction. */
 				--s;
 			if (errno == ERANGE) {
-				if (lno == LONG_MAX)
+				if (lno == MAX_REC_NUMBER)
 					msgq(sp, M_ERR, "153|Count overflow");
-				else if (lno == LONG_MIN)
-					msgq(sp, M_ERR, "154|Count underflow");
 				else
-					msgq(sp, M_SYSERR, NULL);
+					msgq(sp, M_ERR, "154|Count underflow");
 				return (1);
 			}
 			/*



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20110528031803.7A27C106564A>