Improve the parsing of iscsi URLs and validate the input.

Generate better error messages when a badly formed URL is given
and an error string that points to the field there is a problem with.
This commit is contained in:
Ronnie Sahlberg
2010-12-31 09:44:14 +11:00
parent 2b30e3a7fe
commit 46199d2f59
2 changed files with 26 additions and 6 deletions

View File

@@ -194,12 +194,14 @@ int main(int argc, const char *argv[])
if (url == NULL) {
fprintf(stderr, "You must specify the URL\n");
fprintf(stderr, " iscsi://[<username>[%%<password>]@]<host>[:<port>]/<target-iqn>/<lun>\n");
fprintf(stderr, " iscsi://[<username>[%%<password>]@]<host>"
"[:<port>]/<target-iqn>/<lun>\n");
exit(10);
}
iscsi_url = iscsi_parse_full_url(iscsi, url);
if (iscsi_url == NULL) {
fprintf(stderr, "Failed to parse URL : %s %s\n", url, iscsi_get_error(iscsi));
fprintf(stderr, "Failed to parse URL: %s\n",
iscsi_get_error(iscsi));
exit(10);
}