From 345c35a6361f9fb30cb4a2f613ec3ff392a0d8be Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 16 Apr 2017 16:59:01 +0100 Subject: ipif: eat_optionalstr: do not crash on end of argument list Signed-off-by: Ian Jackson --- ipif/service.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/ipif/service.c b/ipif/service.c index b401a5c..7821a46 100644 --- a/ipif/service.c +++ b/ipif/service.c @@ -329,13 +329,17 @@ static char *eat_optionalstr(const char **argp, const char *def) { ptrdiff_t len; const char *start= *argp; - const char *comma= strchr(start, ','); - if (comma) { - len= comma - start; - *argp= comma + 1; + if (!start) { + len = 0; } else { - len= strlen(start); - *argp= start + len; + const char *comma= strchr(start, ','); + if (comma) { + len= comma - start; + *argp= comma + 1; + } else { + len= strlen(start); + *argp= start + len; + } } if (!len) { start= def; -- cgit v1.2.3