MFC r270256:

Always check the limits of array index variables before using them.

Obtained from:	DragonFlyBSD
This commit is contained in:
Pedro F. Giffuni 2014-08-28 18:11:05 +00:00
parent daa4d98d74
commit 09ba6e4823
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/stable/10/; revision=270756
3 changed files with 4 additions and 4 deletions

View File

@ -237,7 +237,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)

View File

@ -216,14 +216,14 @@ lmc_parse(char *lm_p, size_t lm_len)
p = NULL;
while (cnt < lm_len) {
i = 0;
while (lm_p[cnt] != '\n' && cnt < lm_len &&
while (cnt < lm_len && lm_p[cnt] != '\n' &&
i < sizeof(line) - 1) {
line[i] = lm_p[cnt];
cnt++;
i++;
}
line[i] = '\0';
while (lm_p[cnt] != '\n' && cnt < lm_len)
while (cnt < lm_len && lm_p[cnt] != '\n')
cnt++;
/* skip over nl */
cnt++;

View File

@ -81,7 +81,7 @@ edit1(int *msgvec, int type)
/*
* Deal with each message to be edited . . .
*/
for (i = 0; msgvec[i] && i < msgCount; i++) {
for (i = 0; i < msgCount && msgvec[i]; i++) {
sig_t sigint;
if (i > 0) {