Hi,
we've had a request in the Debian bug tracker for a few years to ignore
trailing spaces when reading values from the configuration file (see
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=595660). Also, there's
a note in config.c:219 "Needs just a bit work to fix the parser to care
about ' ' or '\t' after the wanted option..." - and tonight, I felt like
I could do something about that:
--- a/config.c
+++ b/config.c
@@ -529,9 +529,16 @@
configs[config_names[i].nm] = config_names[i].name;
break;
}
- if (configs[config_names[i].nm] == NULL)
- configs[config_names[i].nm] =
- strdup(line + strlen(config_names[i].name));
+ /* get option value, skipping leading and trailing whitespace */
+ if (configs[config_names[i].nm] == NULL) {
+ size_t start;
+ for (start = strlen(config_names[i].name); line[start] == ' ' || line[start] == '\t'; start++)
+ ;
+ llen--;
+ for ( ; line[llen] == ' ' || line[llen] == '\t' ; llen--)
+ line[llen] = 0;
+ configs[config_names[i].nm] = strdup(line + start);
+ }
if (configs[config_names[i].nm] == NULL)
error(1, errno, "can't allocate memory");
break;
One thing to keep in mind might be people with a password ending in
blanks, but then that's just asking for trouble...
Florian
_______________________________________________
vpnc-devel mailing list
vpnc-devel@unix-ag.uni-kl.de
https://lists.unix-ag.uni-kl.de/mailman/listinfo/vpnc-devel
http://www.unix-ag.uni-kl.de/~massar/vpnc/
we've had a request in the Debian bug tracker for a few years to ignore
trailing spaces when reading values from the configuration file (see
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=595660). Also, there's
a note in config.c:219 "Needs just a bit work to fix the parser to care
about ' ' or '\t' after the wanted option..." - and tonight, I felt like
I could do something about that:
--- a/config.c
+++ b/config.c
@@ -529,9 +529,16 @@
configs[config_names[i].nm] = config_names[i].name;
break;
}
- if (configs[config_names[i].nm] == NULL)
- configs[config_names[i].nm] =
- strdup(line + strlen(config_names[i].name));
+ /* get option value, skipping leading and trailing whitespace */
+ if (configs[config_names[i].nm] == NULL) {
+ size_t start;
+ for (start = strlen(config_names[i].name); line[start] == ' ' || line[start] == '\t'; start++)
+ ;
+ llen--;
+ for ( ; line[llen] == ' ' || line[llen] == '\t' ; llen--)
+ line[llen] = 0;
+ configs[config_names[i].nm] = strdup(line + start);
+ }
if (configs[config_names[i].nm] == NULL)
error(1, errno, "can't allocate memory");
break;
One thing to keep in mind might be people with a password ending in
blanks, but then that's just asking for trouble...
Florian
_______________________________________________
vpnc-devel mailing list
vpnc-devel@unix-ag.uni-kl.de
https://lists.unix-ag.uni-kl.de/mailman/listinfo/vpnc-devel
http://www.unix-ag.uni-kl.de/~massar/vpnc/