diff options
author | kensmith <kensmith@FreeBSD.org> | 2007-10-30 05:03:37 +0000 |
---|---|---|
committer | kensmith <kensmith@FreeBSD.org> | 2007-10-30 05:03:37 +0000 |
commit | 9a82deac9e7798e8b266554e32ecacef71ffdee1 (patch) | |
tree | 7da16b4aad42f7dd98080266b753a41aee74e523 /usr.sbin/sysinstall/dmenu.c | |
parent | 9a9592dceb6f0e4272fe29a22e426edd9092ae74 (diff) | |
download | FreeBSD-src-9a82deac9e7798e8b266554e32ecacef71ffdee1.zip FreeBSD-src-9a82deac9e7798e8b266554e32ecacef71ffdee1.tar.gz |
Selecting amd and a few other things in the Networking config section
caused a segfault. It turns out that in pre-7.0 systems if you do
getenv("amd_enable=YES") it will return the setting of the environment
variable "amd_enable" but now it returns NULL. I think I found the
places where sysinstall was potentially relying on that old behavior.
Fix is to make a copy of the string to be used for the getenv(3) call,
look for a '=' character in it, and replace it with '\0' if one is
found. Stuck to sysinstall's typical coding standards despite urges
to do otherwise.
PR: 117642
MFC after: 2 days
Diffstat (limited to 'usr.sbin/sysinstall/dmenu.c')
-rw-r--r-- | usr.sbin/sysinstall/dmenu.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/usr.sbin/sysinstall/dmenu.c b/usr.sbin/sysinstall/dmenu.c index a197188..1aef667 100644 --- a/usr.sbin/sysinstall/dmenu.c +++ b/usr.sbin/sysinstall/dmenu.c @@ -169,19 +169,23 @@ dmenuToggleVariable(dialogMenuItem *tmp) int dmenuISetVariable(dialogMenuItem *tmp) { - char *ans, *var; + char *ans, *p, *var; - if (!(var = (char *)tmp->data)) { + if (!(var = strdup((char *)tmp->data))) { msgConfirm("Incorrect data field for `%s'!", tmp->title); return DITEM_FAILURE; } + if ((p = index(var, '=')) != NULL) + *p = '\0'; ans = msgGetInput(variable_get(var), tmp->title, 1); - if (!ans) + if (!ans) { + free(var); return DITEM_FAILURE; - else if (!*ans) + } else if (!*ans) variable_unset(var); else variable_set2(var, ans, *var != '_'); + free(var); return DITEM_SUCCESS; } |