From: Jaakko Heinonen Date: Sat, 22 Nov 2003 13:46:02 +0000 (+0000) Subject: custom field update X-Git-Tag: upstream/0.6.1~2^2~230 X-Git-Url: https://git.deb.at/w?a=commitdiff_plain;h=d05a5b2a5dc33e0058bd01d194d2515c33ea0ebc;p=pkg%2Fabook.git custom field update --- diff --git a/database.c b/database.c index cf4f966..add1db0 100644 --- a/database.c +++ b/database.c @@ -524,6 +524,9 @@ assign_fieldname(const char *name, int i) { char *s; + assert(name); + assert(i >= 0 && i < ITEM_FIELDS); + if(strcasecmp(abook_fields[i].name, name)) { /* name differs */ /* * check if we are overwriting statically allocated default @@ -545,6 +548,8 @@ change_custom_field_name(const char *name, int n) int i; char keyname[21]; + assert(name); + snprintf(keyname, sizeof(keyname), "custom%d", n); for(i = CUSTOM_MIN; i <= CUSTOM_MAX; i++) { diff --git a/options.c b/options.c index fb5c7a6..9724103 100644 --- a/options.c +++ b/options.c @@ -283,6 +283,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) { @@ -298,10 +300,8 @@ opt_parse_customfield(buffer *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)); + len = (b -> ptr - p); + strncpy(num, p, min(sizeof(num) - 1, len)); n = atoi(num); find_token_start(b);