+ cp = "permitopen=\"";
+ if (strncasecmp(opts, cp, strlen(cp)) == 0) {
+ u_short port;
+ char *c, *ep;
+ char *patterns = xmalloc(strlen(opts) + 1);
+
+ opts += strlen(cp);
+ i = 0;
+ while (*opts) {
+ if (*opts == '"')
+ break;
+ if (*opts == '\\' && opts[1] == '"') {
+ opts += 2;
+ patterns[i++] = '"';
+ continue;
+ }
+ patterns[i++] = *opts++;
+ }
+ if (!*opts) {
+ debug("%.100s, line %lu: missing end quote",
+ file, linenum);
+ packet_send_debug("%.100s, line %lu: missing end quote",
+ file, linenum);
+ xfree(patterns);
+ goto bad_option;
+ }
+ patterns[i] = 0;
+ opts++;
+ c = strchr(patterns, ':');
+ if (c == NULL) {
+ debug("%.100s, line %lu: permitopen: missing colon <%.100s>",
+ file, linenum, patterns);
+ packet_send_debug("%.100s, line %lu: missing colon",
+ file, linenum);
+ xfree(patterns);
+ goto bad_option;
+ }
+ *c = 0;
+ c++;
+ port = strtol(c, &ep, 0);
+ if (c == ep) {
+ debug("%.100s, line %lu: permitopen: missing port <%.100s>",
+ file, linenum, patterns);
+ packet_send_debug("%.100s, line %lu: missing port",
+ file, linenum);
+ xfree(patterns);
+ goto bad_option;
+ }
+ channel_add_permitted_opens(patterns, port);
+ xfree(patterns);
+ goto next_option;
+ }