Mailing List Archive

NessusClient/nessus comm.c,1.20,1.21
Update of /usr/local/cvs/NessusClient/nessus
In directory raccoon.nessus.org:/tmp/cvs-serv76603

Modified Files:
comm.c
Log Message:
Another fix about the radio button values problem.
This fix makes old nessusrc files with only a single
value for radio buttons still work nicely:
The value is kept as configured value because
the other values received from the server
will be appended properly as ";" separated list.
A bit hackish, but it works. And it helps to allow
people keeping their old nessusrc files who migrate
from old gtk client or from early RCs of NessusClient 1.0.


Index: comm.c
===================================================================
RCS file: /usr/local/cvs/NessusClient/nessus/comm.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- comm.c 18 May 2006 14:44:39 -0000 1.20
+++ comm.c 19 May 2006 14:12:21 -0000 1.21
@@ -422,6 +422,44 @@
value = v;
}

+ /* Check whether it is a radiobutton plugin preference and whether
+ * it's value has no ';'. If so, it comes from an old, broken nessusrc file
+ * and we have to repair it:
+ * Make the found value the first one and add all others reported from the
+ * server (in variable v) append to it, separated by semicolons.
+ * This will keep the old value the selected one.
+ */
+ if (! strcmp(type, "radio") && ! strchr(value, ';')) {
+ char * s = strstr(v, value);
+ if (s) {
+ if (s == v)
+ /* it is the first in the list anyway, so simply take
+ * the server string */
+ value = estrdup(v);
+ else {
+ /* append the stuff before the found substring to value */
+ s[0] = 0;
+ value = (char *) erealloc(value, strlen(value) + 1 + strlen(v) + 1);
+ value = strcat(value, ";");
+ value = strcat(value, v);
+
+ /* take care of the stuff after the found substring and append
+ * it also to value */
+ v = strstr(s, ";");
+ if (v) {
+ *v ++;
+ value = (char *) erealloc(value, strlen(value) + strlen(v) + 1);
+ value = strcat(value, v);
+ } else {
+ /* in this case we a ; to much in value already */
+ value[strlen(value)-1] = 0;
+ }
+ }
+ } else
+ /* should acutally not happen, but then take server string */
+ value = estrdup(v);
+ }
+
arg_add_value(prf, "value", ARG_STRING, strlen(value), value);
arg_add_value(prf, "type", ARG_STRING, strlen(type), type);
arg_add_value(prf, "fullname", ARG_STRING, strlen(fullname), fullname);

_______________________________________________
Nessus-cvs mailing list
Nessus-cvs@list.nessus.org
http://mail.nessus.org/mailman/listinfo/nessus-cvs