summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2016-02-18 11:29:36 +0100
committerJosé Bollo <jose.bollo@iot.bzh>2016-02-18 11:29:36 +0100
commit369b595ca0a618ba8188d92ae26c4219625caa3d (patch)
tree20f044780e44bd10ea29aba45d18acaae4a2813d
parentba3c77af3bdbc96e09aa27a6b3778162644eb3b1 (diff)
main: fix parsing of option alias
Change-Id: Ib0eb70e94fabc61ef6ceb22bafa6006d759a7984 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
-rw-r--r--src/main.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/main.c b/src/main.c
index 78d7f79e..74e8745e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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);
}