return -err;
}
-
+
return 0;
}
!strcasecmp(this->fingerprint, fingerprint))
return 0;
}
-
+
while (1) {
char buf[80];
char *details;
free(details);
fprintf(stderr, _("SHA1 fingerprint: %s\n"), fingerprint);
}
-
}
if (non_inter) {
vpn_progress(vpninfo, PRG_ERR,
_("User input required in non-interactive mode\n"));
- return -EINVAL;
+ goto err;
}
fprintf(stderr, "%s [", opt->label);
for (i = 0; i < select_opt->nr_choices; i++) {
fflush(stderr);
if (!fgets(response, sizeof(response), stdin) || !strlen(response))
- return -EINVAL;
+ goto err;
p = strchr(response, '\n');
if (p)
vpn_progress(vpninfo, PRG_ERR,
_("Auth choice \"%s\" not valid\n"),
response);
- return -EINVAL;
+ goto err;
}
}
}
!strcmp(opt->name, "username")) {
opt->value = strdup(vpninfo->username);
if (!opt->value)
- return -ENOMEM;
+ goto err;
} else if (non_inter) {
vpn_progress(vpninfo, PRG_ERR,
_("User input required in non-interactive mode\n"));
- return -EINVAL;
+ goto err;
} else {
opt->value=malloc(80);
if (!opt->value)
- return -ENOMEM;
+ goto err;
fprintf(stderr, "%s", opt->label);
fflush(stderr);
if (!fgets(opt->value, 80, stdin) || !strlen(opt->value))
- return -EINVAL;
+ goto err;
p = strchr(opt->value, '\n');
if (p)
opt->value = vpninfo->password;
vpninfo->password = NULL;
if (!opt->value)
- return -ENOMEM;
+ goto err;
} else if (non_inter) {
vpn_progress(vpninfo, PRG_ERR,
_("User input required in non-interactive mode\n"));
- return -EINVAL;
+ goto err;
} else {
struct termios t;
opt->value=malloc(80);
if (!opt->value)
- return -ENOMEM;
+ goto err;
fprintf(stderr, "%s", opt->label);
fflush(stderr);
t.c_lflag |= ECHO;
tcsetattr(0, TCSANOW, &t);
fprintf(stderr, "\n");
-
+
if (!p || !strlen(opt->value))
- return -EINVAL;
+ goto err;
p = strchr(opt->value, '\n');
if (p)
}
return 0;
+
+ err:
+ for (opt = form->opts; opt; opt = opt->next) {
+ if (opt->value && (opt->type == OC_FORM_OPT_TEXT ||
+ opt->type == OC_FORM_OPT_PASSWORD)) {
+ free(opt->value);
+ opt->value = NULL;
+ }
+ }
+ return -EINVAL;
}