aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Dokuchaev <danfe@FreeBSD.org>2016-04-29 13:58:01 +0000
committerAlexey Dokuchaev <danfe@FreeBSD.org>2016-04-29 13:58:01 +0000
commit89af640651b530908bc647968b7b960e564322f6 (patch)
treeec907bb8344c7cc7b5ac5c1a8605a157437ff553
parent0c318c36dbe477476ab112c795a231c75001dc0b (diff)
MFC r270256, r298640:
ed(1): switch two statements so we check the index before dereferencing. Approved by: pfg
Notes
Notes: svn path=/stable/8/; revision=298785
-rw-r--r--bin/ed/cbc.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/bin/ed/cbc.c b/bin/ed/cbc.c
index 52e99998d67c..7d8113c7e65e 100644
--- a/bin/ed/cbc.c
+++ b/bin/ed/cbc.c
@@ -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)