fix null pointer deref on empty nameref assignment (no ‘=’)
found by Goodbox on IRC
This commit is contained in:
parent
968dc7a764
commit
40954ce437
6
check.t
6
check.t
@ -1,4 +1,4 @@
|
|||||||
# $MirOS: src/bin/mksh/check.t,v 1.659 2014/10/03 17:32:09 tg Exp $
|
# $MirOS: src/bin/mksh/check.t,v 1.660 2014/10/04 11:47:16 tg Exp $
|
||||||
# OpenBSD src/regress/bin/ksh updated: 2013/12/02 20:39:44
|
# OpenBSD src/regress/bin/ksh updated: 2013/12/02 20:39:44
|
||||||
#-
|
#-
|
||||||
# Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
# Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
||||||
@ -27,7 +27,7 @@
|
|||||||
# http://www.freebsd.org/cgi/cvsweb.cgi/src/tools/regression/bin/test/regress.sh?rev=HEAD
|
# http://www.freebsd.org/cgi/cvsweb.cgi/src/tools/regression/bin/test/regress.sh?rev=HEAD
|
||||||
|
|
||||||
expected-stdout:
|
expected-stdout:
|
||||||
@(#)MIRBSD KSH R50 2014/10/03
|
@(#)MIRBSD KSH R50 2014/10/04
|
||||||
description:
|
description:
|
||||||
Check version of shell.
|
Check version of shell.
|
||||||
stdin:
|
stdin:
|
||||||
@ -36,7 +36,7 @@ name: KSH_VERSION
|
|||||||
category: shell:legacy-no
|
category: shell:legacy-no
|
||||||
---
|
---
|
||||||
expected-stdout:
|
expected-stdout:
|
||||||
@(#)LEGACY KSH R50 2014/10/03
|
@(#)LEGACY KSH R50 2014/10/04
|
||||||
description:
|
description:
|
||||||
Check version of legacy shell.
|
Check version of legacy shell.
|
||||||
stdin:
|
stdin:
|
||||||
|
4
sh.h
4
sh.h
@ -169,9 +169,9 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef EXTERN
|
#ifdef EXTERN
|
||||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.695 2014/10/03 17:32:12 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.696 2014/10/04 11:47:18 tg Exp $");
|
||||||
#endif
|
#endif
|
||||||
#define MKSH_VERSION "R50 2014/10/03"
|
#define MKSH_VERSION "R50 2014/10/04"
|
||||||
|
|
||||||
/* arithmetic types: C implementation */
|
/* arithmetic types: C implementation */
|
||||||
#if !HAVE_CAN_INTTYPES
|
#if !HAVE_CAN_INTTYPES
|
||||||
|
8
var.c
8
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.182 2014/10/03 17:20:03 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.183 2014/10/04 11:47:19 tg Exp $");
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Variables
|
* Variables
|
||||||
@ -784,8 +784,9 @@ typeset(const char *var, uint32_t set, uint32_t clr, int field, int base)
|
|||||||
/* find value if variable already exists */
|
/* find value if variable already exists */
|
||||||
if ((qval = val) == NULL) {
|
if ((qval = val) == NULL) {
|
||||||
varsearch(e->loc, &vp, tvar, hash(tvar));
|
varsearch(e->loc, &vp, tvar, hash(tvar));
|
||||||
if (vp != NULL)
|
if (vp == NULL)
|
||||||
qval = str_val(vp);
|
goto nameref_empty;
|
||||||
|
qval = str_val(vp);
|
||||||
}
|
}
|
||||||
/* 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);
|
||||||
@ -803,6 +804,7 @@ typeset(const char *var, uint32_t set, uint32_t clr, int field, int base)
|
|||||||
case '-':
|
case '-':
|
||||||
goto nameref_rhs_checked;
|
goto nameref_rhs_checked;
|
||||||
}
|
}
|
||||||
|
nameref_empty:
|
||||||
errorf("%s: %s", var, "empty nameref target");
|
errorf("%s: %s", var, "empty nameref target");
|
||||||
}
|
}
|
||||||
len = (*ccp == '[') ? array_ref_len(ccp) : 0;
|
len = (*ccp == '[') ? array_ref_len(ccp) : 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user