diff options
author | José Bollo <jose.bollo@iot.bzh> | 2016-02-18 11:29:36 +0100 |
---|---|---|
committer | José Bollo <jose.bollo@iot.bzh> | 2016-02-18 11:29:36 +0100 |
commit | 369b595ca0a618ba8188d92ae26c4219625caa3d (patch) | |
tree | 20f044780e44bd10ea29aba45d18acaae4a2813d | |
parent | ba3c77af3bdbc96e09aa27a6b3778162644eb3b1 (diff) |
main: fix parsing of option alias
Change-Id: Ib0eb70e94fabc61ef6ceb22bafa6006d759a7984
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
-rw-r--r-- | src/main.c | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -345,10 +345,14 @@ int main(int argc, char *argv[]) { if (optarg == 0) goto needValueForOption; if (aliascount < MAX_ALIAS) { aliasdir[aliascount].url = strsep(&optarg,":"); - aliasdir[aliascount].path = strsep(&optarg,":"); - aliasdir[aliascount].len = strlen(aliasdir[aliascount].url); - if (verbose) fprintf(stderr, "Alias url=%s path=%s\n", aliasdir[aliascount].url, aliasdir[aliascount].path); - aliascount++; + if (optarg == NULL) { + fprintf(stderr, "missing ':' in alias %s, ignored\n", aliasdir[aliascount].url); + } else { + aliasdir[aliascount].path = optarg; + aliasdir[aliascount].len = strlen(aliasdir[aliascount].url); + if (verbose) fprintf(stderr, "Alias url=%s path=%s\n", aliasdir[aliascount].url, aliasdir[aliascount].path); + aliascount++; + } } else { fprintf(stderr, "Too many aliases [max:%s] %s ignored\n", optarg, MAX_ALIAS-1); } |