fix Coverity CID #8, #9

it's wrong to use strchr(s, 0) to look for the NUL byte, because in some
environments it apparently might return NULL

use new macro strnul = s+strlen(s) instead (not side-effect safe tho)
This commit is contained in:
tg
2007-05-13 19:14:05 +00:00
parent 655b50a7d1
commit a84655e3e0
3 changed files with 10 additions and 7 deletions

4
lex.c
View File

@@ -2,7 +2,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.31 2007/05/13 18:07:22 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.32 2007/05/13 19:14:04 tg Exp $");
/* Structure to keep track of the lexing state and the various pieces of info
* needed for each particular state. */
@@ -886,7 +886,7 @@ getsc__(void)
source->flags |= s->flags & SF_ALIAS;
s = source;
} else if (*s->u.tblp->val.s &&
ksh_isspace(strchr(s->u.tblp->val.s, 0)[-1])) {
ksh_isspace(strnul(s->u.tblp->val.s)[-1])) {
source = s = s->next; /* pop source stack */
/* Note that this alias ended with a space,
* enabling alias expansion on the following