From: Jaakko Heinonen Date: Wed, 6 Sep 2006 08:48:33 +0000 (+0000) Subject: - make sure that len - 1 is never < 0 X-Git-Tag: upstream/0.6.1~2^2~85 X-Git-Url: https://git.deb.at/?p=pkg%2Fabook.git;a=commitdiff_plain;h=515b441b0478ac01f1c5dfef3810a7778f899c9c - make sure that len - 1 is never < 0 - add some asserts --- diff --git a/options.c b/options.c index 28aaf7c..84f08ca 100644 --- a/options.c +++ b/options.c @@ -279,11 +279,12 @@ opt_set_set_option(char *p, struct option *opt) { int len; - strtrim(p); + assert(p); + strtrim(p); len = strlen(p); - if(p[len - 1] == '\"' && *p == '\"') { + if(*p == '\"' && p[len - 1] == '\"') { if(len < 3) return _("invalid value"); p[len - 1] = 0; @@ -318,6 +319,9 @@ opt_set_option(char *var, char *p) { int i; + assert(var); + assert(p); + for(i = 0; abook_vars[i].option; i++) if(!strcmp(abook_vars[i].option, var)) return opt_set_set_option(p, &abook_vars[i]);