socsvn commit: r222497 - in soc2011/zy/nvi-iconv/head/usr.bin/nvi: common ex

zy at FreeBSD.org zy at FreeBSD.org
Sat May 28 03:18:05 UTC 2011


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);
 			}
 			/*


More information about the svn-soc-all mailing list