X-Git-Url: https://git.deb.at/w?a=blobdiff_plain;f=options.c;h=41bde1b920644eb332b4c2d48548403003b8a5dc;hb=67d7885c6f6e11e16488cac7117c503e03248183;hp=fb5c7a635d61e10c8340e774bf280e1766bdb555;hpb=208968222b63ab08f95b0ad6d882cfc4ab22dda5;p=pkg%2Fabook.git diff --git a/options.c b/options.c index fb5c7a6..41bde1b 100644 --- a/options.c +++ b/options.c @@ -257,6 +257,8 @@ opt_set_set_option(char *var, char *p, struct option *opt) else return "invalid value"; break; + default: + assert(0); } return NULL; @@ -283,6 +285,8 @@ opt_parse_set(buffer *b) return "unknown option"; } +#include "database.h" /* needed for change_custom_field_name */ + static char * opt_parse_customfield(buffer *b) { @@ -291,18 +295,14 @@ opt_parse_customfield(buffer *b) size_t len; find_token_start(b); - p = b -> ptr; - find_token_end(b); memset(num, 0, sizeof(num)); - if((len = (b -> ptr - p)) > sizeof(num)) - return "invalid custom field number"; - - strncpy(num, p, min(sizeof(num), len)); - n = atoi(num); + len = (b -> ptr - p); + strncpy(num, p, min(sizeof(num) - 1, len)); + n = safe_atoi(num); find_token_start(b);