Skip to content

Commit

Permalink
sh: Avoid out-of-bounds access in setoptionbyindex() for 'set -o nolog'.
Browse files Browse the repository at this point in the history
Reported by:	hrs
  • Loading branch information
jillest committed Mar 9, 2016
1 parent efc97b3 commit e1e2ce9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions bin/sh/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ minus_o(char *name, int val)
static void
setoptionbyindex(int idx, int val)
{
if (optletter[idx] == 'p' && !val && privileged) {
if (&optval[idx] == &privileged && !val && privileged) {
if (setgid(getgid()) == -1)
error("setgid");
if (setuid(getuid()) == -1)
Expand All @@ -294,9 +294,9 @@ setoptionbyindex(int idx, int val)
optval[idx] = val;
if (val) {
/* #%$ hack for ksh semantics */
if (optletter[idx] == 'V')
if (&optval[idx] == &Vflag)
Eflag = 0;
else if (optletter[idx] == 'E')
else if (&optval[idx] == &Eflag)
Vflag = 0;
}
}
Expand Down

0 comments on commit e1e2ce9

Please sign in to comment.