From 369b595ca0a618ba8188d92ae26c4219625caa3d Mon Sep 17 00:00:00 2001 From: José Bollo Date: Thu, 18 Feb 2016 11:29:36 +0100 Subject: main: fix parsing of option alias MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ib0eb70e94fabc61ef6ceb22bafa6006d759a7984 Signed-off-by: José Bollo --- src/main.c | 12 ++++++++---- 1 file 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); } -- cgit 1.2.3-korg