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
This commit is contained in:
Ken Smith 2007-10-30 05:03:37 +00:00
parent 0f10497bce
commit 327433d2a2
2 changed files with 14 additions and 5 deletions

View File

@ -871,13 +871,18 @@ configNFSServer(dialogMenuItem *self)
int
configRpcBind(dialogMenuItem *self)
{
char *tmp, *tmp2;
int retval = 0;
int doupdate = 1;
if (self != NULL) {
retval = dmenuToggleVariable(self);
if (strcmp(variable_get(self->data), "YES") != 0)
tmp = strdup(self->data);
if ((tmp2 = index(tmp, '=')) != NULL)
*tmp2 = '\0';
if (strcmp(variable_get(tmp), "YES") != 0)
doupdate = 0;
free(tmp);
}
if (doupdate && strcmp(variable_get(VAR_RPCBIND_ENABLE), "YES") != 0) {

View File

@ -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;
}