X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=config.c;h=d0931f8905bd52a61dcdb7a970674aba21f4060d;hb=ace6564954d7f31d9ba46c357bf4fe317f98d579;hp=3f0ea9317a83e495e45b479fbb59fb1b0ebb657a;hpb=c90f047476c9743c7ab1505022adfb70a2e4a98a;p=PuTTY.git diff --git a/config.c b/config.c index 3f0ea931..d0931f89 100644 --- a/config.c +++ b/config.c @@ -1016,19 +1016,25 @@ static void portfwd_handler(union control *ctrl, void *dlg, *p = '\0'; p = cfg->portfwd; while (*p) { + if (strcmp(p,str) == 0) { + dlg_error_msg(dlg, "Specified forwarding already exists"); + break; + } while (*p) p++; p++; } - if ((p - cfg->portfwd) + strlen(str) + 2 <= - sizeof(cfg->portfwd)) { - strcpy(p, str); - p[strlen(str) + 1] = '\0'; - dlg_listbox_add(pfd->listbox, dlg, str); - dlg_editbox_set(pfd->sourcebox, dlg, ""); - dlg_editbox_set(pfd->destbox, dlg, ""); - } else { - dlg_error_msg(dlg, "Too many forwardings"); + if (!*p) { + if ((p - cfg->portfwd) + strlen(str) + 2 <= + sizeof(cfg->portfwd)) { + strcpy(p, str); + p[strlen(str) + 1] = '\0'; + dlg_listbox_add(pfd->listbox, dlg, str); + dlg_editbox_set(pfd->sourcebox, dlg, ""); + dlg_editbox_set(pfd->destbox, dlg, ""); + } else { + dlg_error_msg(dlg, "Too many forwardings"); + } } } else if (ctrl == pfd->rembutton) { int i = dlg_listbox_index(pfd->listbox, dlg);