val != NULL;
val = conf_get_str_strs(conf, CONF_portfwd, key, &key)) {
char *p;
- if (!strcmp(val, "D"))
- p = dupprintf("D%s\t", key+1);
- else
+ if (!strcmp(val, "D")) {
+ char *L;
+ /*
+ * A dynamic forwarding is stored as L12345=D or
+ * 6L12345=D (since it's mutually exclusive with
+ * L12345=anything else), but displayed as D12345
+ * to match the fiction that 'Local', 'Remote' and
+ * 'Dynamic' are three distinct modes and also to
+ * align with OpenSSH's command line option syntax
+ * that people will already be used to. So, for
+ * display purposes, find the L in the key string
+ * and turn it into a D.
+ */
+ p = dupprintf("%s\t", key);
+ L = strchr(p, 'L');
+ if (L) *L = 'D';
+ } else
p = dupprintf("%s\t%s", key, val);
dlg_listbox_add(ctrl, dlg, p);
sfree(p);
val = q;
*q = '\0';
- if (primary == CONF_portfwd && buf[0] == 'D') {
+ if (primary == CONF_portfwd && strchr(buf, 'D') != NULL) {
/*
* Backwards-compatibility hack: dynamic forwardings are
* indexed in the data store as a third type letter in the
* _listening_ on a local port, and are hence mutually
* exclusive on the same port number. So here we translate
* the legacy storage format into the sensible internal
- * form.
+ * form, by finding the D and turning it into a L.
*/
- char *newkey = dupcat("L", buf+1, NULL);
+ char *newkey = dupstr(buf);
+ *strchr(newkey, 'D') = 'L';
conf_set_str_str(conf, primary, newkey, "D");
sfree(newkey);
} else {
* conceptually incoherent legacy storage format (key
* "D<port>", value empty).
*/
+ char *L;
+
realkey = key; /* restore it at end of loop */
val = "";
- key = dupcat("D", key+1, NULL);
+ key = dupstr(key);
+ L = strchr(key, 'L');
+ if (L) *L = 'D';
} else {
realkey = NULL;
}