MFC r270256, r298640:

ed(1): switch two statements so we check the index before dereferencing.

Approved by:	pfg
This commit is contained in:
Alexey Dokuchaev 2016-04-29 13:58:01 +00:00
parent 0c318c36db
commit 89af640651
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/stable/8/; revision=298785

View File

@ -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)