svn commit: r298785 - stable/8/bin/ed

Alexey Dokuchaev danfe at FreeBSD.org
Fri Apr 29 13:58:02 UTC 2016


Author: danfe (ports committer)
Date: Fri Apr 29 13:58:01 2016
New Revision: 298785
URL: https://svnweb.freebsd.org/changeset/base/298785

Log:
  MFC r270256, r298640:
  
    ed(1): switch two statements so we check the index before dereferencing.
  
  Approved by:	pfg

Modified:
  stable/8/bin/ed/cbc.c
Directory Properties:
  stable/8/bin/ed/   (props changed)

Modified: stable/8/bin/ed/cbc.c
==============================================================================
--- stable/8/bin/ed/cbc.c	Fri Apr 29 12:23:56 2016	(r298784)
+++ stable/8/bin/ed/cbc.c	Fri Apr 29 13:58:01 2016	(r298785)
@@ -243,7 +243,7 @@ expand_des_key(char *obuf, char *kbuf)
 		/*
 		 * now translate it, bombing on any illegal hex digit
 		 */
-		for (i = 0; kbuf[i] && i < 16; i++)
+		for (i = 0; i < 16 && kbuf[i]; i++)
 			if ((nbuf[i] = hex_to_binary((int) kbuf[i], 16)) == -1)
 				des_error("bad hex digit in key");
 		while (i < 16)
@@ -263,7 +263,7 @@ expand_des_key(char *obuf, char *kbuf)
 		/*
 		 * now translate it, bombing on any illegal binary digit
 		 */
-		for (i = 0; kbuf[i] && i < 16; i++)
+		for (i = 0; i < 16 && kbuf[i]; i++)
 			if ((nbuf[i] = hex_to_binary((int) kbuf[i], 2)) == -1)
 				des_error("bad binary digit in key");
 		while (i < 64)


More information about the svn-src-all mailing list