From c94a041f43ed36ca867780d84ca3c387d2d72651 Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Wed, 9 Mar 2016 21:00:57 +0000 Subject: [PATCH] sh: Avoid out-of-bounds access in setoptionbyindex() for 'set -o nolog'. Reported by: hrs --- bin/sh/options.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/sh/options.c b/bin/sh/options.c index 70a09c3c91d9..340d7e0b30ea 100644 --- a/bin/sh/options.c +++ b/bin/sh/options.c @@ -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) @@ -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; } }