From 67f03191ad5c196e6fc076398cd249c4ded327cb Mon Sep 17 00:00:00 2001 From: jkh Date: Wed, 8 Mar 2000 14:20:26 +0000 Subject: [PATCH] Whoops - really make the "fix" I did to the dmenuToggleVariable logic work. --- release/sysinstall/dmenu.c | 10 ++++++++-- usr.sbin/sade/dmenu.c | 10 ++++++++-- usr.sbin/sysinstall/dmenu.c | 10 ++++++++-- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/release/sysinstall/dmenu.c b/release/sysinstall/dmenu.c index 79762beaaa8c..7f113fc132b3 100644 --- a/release/sysinstall/dmenu.c +++ b/release/sysinstall/dmenu.c @@ -132,15 +132,21 @@ dmenuSetKmapVariable(dialogMenuItem *tmp) int dmenuToggleVariable(dialogMenuItem *tmp) { - char *var; + char *var, *cp; int status; - if (!(var = (char *)tmp->data)) { + if (!(var = strdup((char *)tmp->data))) { msgConfirm("Incorrect data field for `%s'!", tmp->title); return DITEM_FAILURE; } + if (!(cp = index(var, '='))) { + msgConfirm("Data field for %s is not in var=value format!", tmp->title); + return DITEM_FAILURE; + } status = variable_check(var); + *cp = '\0'; variable_set2(var, status ? "NO" : "YES", *var != '_'); + free(var); return DITEM_SUCCESS; } diff --git a/usr.sbin/sade/dmenu.c b/usr.sbin/sade/dmenu.c index 79762beaaa8c..7f113fc132b3 100644 --- a/usr.sbin/sade/dmenu.c +++ b/usr.sbin/sade/dmenu.c @@ -132,15 +132,21 @@ dmenuSetKmapVariable(dialogMenuItem *tmp) int dmenuToggleVariable(dialogMenuItem *tmp) { - char *var; + char *var, *cp; int status; - if (!(var = (char *)tmp->data)) { + if (!(var = strdup((char *)tmp->data))) { msgConfirm("Incorrect data field for `%s'!", tmp->title); return DITEM_FAILURE; } + if (!(cp = index(var, '='))) { + msgConfirm("Data field for %s is not in var=value format!", tmp->title); + return DITEM_FAILURE; + } status = variable_check(var); + *cp = '\0'; variable_set2(var, status ? "NO" : "YES", *var != '_'); + free(var); return DITEM_SUCCESS; } diff --git a/usr.sbin/sysinstall/dmenu.c b/usr.sbin/sysinstall/dmenu.c index 79762beaaa8c..7f113fc132b3 100644 --- a/usr.sbin/sysinstall/dmenu.c +++ b/usr.sbin/sysinstall/dmenu.c @@ -132,15 +132,21 @@ dmenuSetKmapVariable(dialogMenuItem *tmp) int dmenuToggleVariable(dialogMenuItem *tmp) { - char *var; + char *var, *cp; int status; - if (!(var = (char *)tmp->data)) { + if (!(var = strdup((char *)tmp->data))) { msgConfirm("Incorrect data field for `%s'!", tmp->title); return DITEM_FAILURE; } + if (!(cp = index(var, '='))) { + msgConfirm("Data field for %s is not in var=value format!", tmp->title); + return DITEM_FAILURE; + } status = variable_check(var); + *cp = '\0'; variable_set2(var, status ? "NO" : "YES", *var != '_'); + free(var); return DITEM_SUCCESS; }