From 97ad248f0cbd87cb1e351961b632bf9764f608fe Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Sun, 26 Feb 2012 15:47:43 +0000 Subject: [PATCH] * environ.cc (enum settings): Add setbool. Rename justset to setdword to avoid future problems. (struct parse_thing): Change all justset to setbool for bool variables. (parse_options): Add a case for setbool setting for bool variables since justset (now setdword) always writes a DWORD value, thus potentially overwriting adjacent memory locations. * external.cc (cygwin_internal): Drop extern declaration. --- winsup/cygwin/ChangeLog | 10 ++++++++++ winsup/cygwin/environ.cc | 24 ++++++++++++++++-------- winsup/cygwin/external.cc | 1 - 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 48a5c5e84..e4ddbb744 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,13 @@ +2012-02-26 Corinna Vinschen + + * environ.cc (enum settings): Add setbool. Rename justset to setdword + to avoid future problems. + (struct parse_thing): Change all justset to setbool for bool variables. + (parse_options): Add a case for setbool setting for bool variables + since justset (now setdword) always writes a DWORD value, thus + potentially overwriting adjacent memory locations. + * external.cc (cygwin_internal): Drop extern declaration. + 2012-02-26 Corinna Vinschen * environ.cc (dos_file_warning): Drop declaration. diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc index a99f97cf8..33289d2f5 100644 --- a/winsup/cygwin/environ.cc +++ b/winsup/cygwin/environ.cc @@ -40,8 +40,9 @@ static NO_COPY bool export_settings = false; enum settings { - justset, isfunc, + setdword, + setbool, setbit }; @@ -111,16 +112,16 @@ static struct parse_thing } values[2]; } known[] NO_COPY = { - {"detect_bloda", {&detect_bloda}, justset, NULL, {{false}, {true}}}, - {"dosfilewarning", {&dos_file_warning}, justset, NULL, {{false}, {true}}}, + {"detect_bloda", {&detect_bloda}, setbool, NULL, {{false}, {true}}}, + {"dosfilewarning", {&dos_file_warning}, setbool, NULL, {{false}, {true}}}, {"error_start", {func: error_start_init}, isfunc, NULL, {{0}, {0}}}, - {"export", {&export_settings}, justset, NULL, {{false}, {true}}}, + {"export", {&export_settings}, setbool, NULL, {{false}, {true}}}, {"glob", {func: glob_init}, isfunc, NULL, {{0}, {s: "normal"}}}, {"proc_retry", {func: set_proc_retry}, isfunc, NULL, {{0}, {5}}}, - {"reset_com", {&reset_com}, justset, NULL, {{false}, {true}}}, + {"reset_com", {&reset_com}, setbool, NULL, {{false}, {true}}}, {"tty", {func: tty_is_gone}, isfunc, NULL, {{0}, {0}}}, - {"winsymlinks", {&allow_winsymlinks}, justset, NULL, {{false}, {true}}}, - {NULL, {0}, justset, 0, {{0}, {0}}} + {"winsymlinks", {&allow_winsymlinks}, setbool, NULL, {{false}, {true}}}, + {NULL, {0}, setdword, 0, {{0}, {0}}} }; /* Parse a string of the form "something=stuff somethingelse=more-stuff", @@ -180,13 +181,20 @@ parse_options (const char *inbuf) k->values[istrue].s : eq); debug_printf ("%s (called func)", k->name); break; - case justset: + case setdword: if (!istrue || !eq) *k->setting.x = k->values[istrue].i; else *k->setting.x = strtol (eq, NULL, 0); debug_printf ("%s %d", k->name, *k->setting.x); break; + case setbool: + if (!istrue || !eq) + *k->setting.b = k->values[istrue].i; + else + *k->setting.b = !!strtol (eq, NULL, 0); + debug_printf ("%s%s", *k->setting.b ? "" : "no", k->name); + break; case setbit: *k->setting.x &= ~k->values[istrue].i; if (istrue || (eq && strtol (eq, NULL, 0))) diff --git a/winsup/cygwin/external.cc b/winsup/cygwin/external.cc index 146dda953..cd86966b8 100644 --- a/winsup/cygwin/external.cc +++ b/winsup/cygwin/external.cc @@ -432,7 +432,6 @@ cygwin_internal (cygwin_getinfo_types t, ...) break; case CW_SET_DOS_FILE_WARNING: { - extern bool dos_file_warning; dos_file_warning = va_arg (arg, int); res = 0; }