don’t read past buffer for empty nameref targets (fmunozs, Valgrind)
This commit is contained in:
parent
539714f78a
commit
85c377dfc2
10
var.c
10
var.c
|
@ -28,7 +28,7 @@
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.199 2016/02/26 18:48:14 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.200 2016/03/01 20:06:15 tg Exp $");
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Variables
|
* Variables
|
||||||
|
@ -829,12 +829,14 @@ typeset(const char *var, uint32_t set, uint32_t clr, int field, int base)
|
||||||
/* check target value for being a valid variable name */
|
/* check target value for being a valid variable name */
|
||||||
ccp = skip_varname(qval, false);
|
ccp = skip_varname(qval, false);
|
||||||
if (ccp == qval) {
|
if (ccp == qval) {
|
||||||
if (ksh_isdigit(qval[0])) {
|
int c;
|
||||||
int c;
|
|
||||||
|
|
||||||
|
if (!(c = (unsigned char)qval[0]))
|
||||||
|
goto nameref_empty;
|
||||||
|
else if (ksh_isdigit(c))
|
||||||
if (getn(qval, &c))
|
if (getn(qval, &c))
|
||||||
goto nameref_rhs_checked;
|
goto nameref_rhs_checked;
|
||||||
} else if (qval[1] == '\0') switch (qval[0]) {
|
else if (qval[1] == '\0') switch (c) {
|
||||||
case '$':
|
case '$':
|
||||||
case '!':
|
case '!':
|
||||||
case '?':
|
case '?':
|
||||||
|
|
Loading…
Reference in New Issue