• fix ${12345678901234567890} segfault (OOB access / integer overflow)

‣ not like oksh did, but using mksh’s built-in features
• handle suggested __pure additions
• revert cid 1004F7F096867C83CF0
  ‣ always use our wcwidth code
  ‣ only use our strlcpy code if none found
• fix a couple of gcc-snapshot and clang/scan-build warnings
• mksh R49~rc1
This commit is contained in:
tg
2014-01-05 21:57:29 +00:00
parent 2f6fa6fb3d
commit 89e774fd7e
13 changed files with 149 additions and 126 deletions

8
var.c
View File

@@ -1,4 +1,4 @@
/* $OpenBSD: var.c,v 1.37 2013/12/18 13:53:12 millert Exp $ */
/* $OpenBSD: var.c,v 1.38 2013/12/20 17:53:09 zhuk Exp $ */
/*-
* Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
@@ -27,7 +27,7 @@
#include <sys/sysctl.h>
#endif
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.175 2014/01/05 19:14:18 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.176 2014/01/05 21:57:29 tg Exp $");
/*-
* Variables
@@ -238,9 +238,7 @@ global(const char *n)
vp->areap = ATEMP;
*vp->name = c;
if (ksh_isdigit(c)) {
for (c = 0; ksh_isdigit(*n); n++)
c = (c * 10) + (*n - '0');
if (c <= l->argc)
if (getn(n, &c) && (c <= l->argc))
/* setstr can't fail here */
setstr(vp, l->argv[c], KSH_RETURN_ERROR);
vp->flag |= RDONLY;