From: Jaakko Heinonen Date: Mon, 11 Jun 2001 12:51:54 +0000 (+0000) Subject: Fixed snprintf related bugs X-Git-Tag: upstream/0.6.1~2^2~366 X-Git-Url: https://git.deb.at/?a=commitdiff_plain;h=a99180ae57f15c923ac78be34df3acb432d8fce7;p=pkg%2Fabook.git Fixed snprintf related bugs --- diff --git a/ChangeLog b/ChangeLog index da9f81a..42dd5a1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,7 @@ - new editor commands - text filter update - query/find code cleanup + - fixed snprintf related bugs 0.4.12 - added man page for abookrc (Alan Ford) diff --git a/abook.c b/abook.c index e01eb42..6147aee 100644 --- a/abook.c +++ b/abook.c @@ -204,7 +204,6 @@ show_usage() } extern list_item *database; -extern int items; static void muttq_print_item(int item) @@ -277,23 +276,23 @@ quit_mutt_query(int status) void launch_mutt(int item) { - int i; + /* + * This is _broken_ + */ +#if 0 + struct db_enumerator e = init_db_enumerator(ENUM_ALL); char email[MAX_EMAIL_LEN]; char *cmd; char *tmp = options_get_str("mutt_command"); - if( !is_valid_item(item) ) - return; - cmd = strconcat(tmp, " '", NULL ); - for(i=0; i < items; i++) { - if( ! is_selected(i) && i != list_current_item() ) - continue; - get_first_email(email, i); - tmp = mkstr("%s \"%s\"", cmd, database[i][NAME]); + db_enumerate_items(e) { + if( e.item != item ); + get_first_email(email, e.item); + tmp = mkstr("%s, \"%s\"", cmd, database[e.item][NAME]); my_free(cmd); - if( *database[i][EMAIL] ) { + if( *database[e.item][EMAIL] ) { cmd = mkstr("%s <%s>", tmp, email); free(tmp); tmp = cmd; @@ -302,7 +301,7 @@ launch_mutt(int item) free(tmp); } - tmp = mkstr("%s%c", cmd, '\''); + tmp = strconcat(cmd, "\'", NULL); free(cmd); cmd = tmp; #ifdef DEBUG @@ -311,6 +310,7 @@ launch_mutt(int item) system(cmd); free(cmd); +#endif } void diff --git a/edit.c b/edit.c index e41d707..feb59be 100644 --- a/edit.c +++ b/edit.c @@ -127,12 +127,12 @@ print_editor_header(int item) get_first_email(email, item); - if( snprintf(header, EDITW_COLS, "%s <%s>", database[item][NAME], - email ) == -1 || !*database[item][EMAIL] ) - if( snprintf(header, EDITW_COLS, "%s", database[item][NAME]) == -1) { - free(header); - return; - } + if( *database[item][EMAIL] ) + snprintf(header, EDITW_COLS, "%s <%s>", + database[item][NAME], + database[item][EMAIL]); + else + snprintf(header, EDITW_COLS, "%s", database[item][NAME]); len = strlen(header); x = (EDITW_COLS - len) / 2; diff --git a/misc.c b/misc.c index eae1e90..1213dd5 100644 --- a/misc.c +++ b/misc.c @@ -123,10 +123,13 @@ mkstr (const char *format, ... ) format, ap); MY_VA_END; - if (n > -1) + if (n > -1 && n < size) return buffer; - size *= 2; + if (n > -1) + size = n + 1; + else + size *= 2; buffer = #ifdef ABOOK_SRC