From: Jeremy Harris Date: Wed, 16 Mar 2016 15:30:57 +0000 (+0000) Subject: tidying: coverity issues X-Git-Tag: exim-4_87_RC7~7 X-Git-Url: https://git.exim.org/exim.git/commitdiff_plain/8d468c4c169a7519d5b172cc049b1d8cc7b1c343 tidying: coverity issues --- diff --git a/src/exim_monitor/em_menu.c b/src/exim_monitor/em_menu.c index 6975e709d..81df0d37c 100644 --- a/src/exim_monitor/em_menu.c +++ b/src/exim_monitor/em_menu.c @@ -556,6 +556,7 @@ static void addrecipAction(Widget w, XtPointer client_data, XtPointer call_data) w = w; /* Keep picky compilers happy */ call_data = call_data; Ustrncpy(actioned_message, client_data, 24); +actioned_message[23] = '\0'; action_required = US"-Mar"; dialog_ref_widget = menushell; create_dialog(US"Recipient address to add?", US""); @@ -572,6 +573,7 @@ static void markdelAction(Widget w, XtPointer client_data, XtPointer call_data) w = w; /* Keep picky compilers happy */ call_data = call_data; Ustrncpy(actioned_message, client_data, 24); +actioned_message[23] = '\0'; action_required = US"-Mmd"; dialog_ref_widget = menushell; create_dialog(US"Recipient address to mark delivered?", US""); @@ -602,6 +604,7 @@ uschar *sender; w = w; /* Keep picky compilers happy */ call_data = call_data; Ustrncpy(actioned_message, client_data, 24); +actioned_message[23] = '\0'; q = find_queue(actioned_message, queue_noop, 0); sender = !q ? US"" : q->sender[0] == 0 ? US"<>" : q->sender; action_required = US"-Mes"; diff --git a/src/src/sieve.c b/src/src/sieve.c index bda482fd1..8f98aebab 100644 --- a/src/src/sieve.c +++ b/src/src/sieve.c @@ -232,6 +232,9 @@ uschar *new = NULL; uschar ch; size_t line; +/* Two passes: one to count output allocation size, second +to do the encoding */ + for (pass=0; pass<=1; ++pass) { line=0; @@ -245,54 +248,47 @@ for (pass=0; pass<=1; ++pass) for (start=src->character,end=start+src->length; start=73) + if (line>=73) /* line length limit */ { if (pass==0) dst->length+=2; else { - *new++='='; + *new++='='; /* line split */ *new++='\n'; } line=0; } - if - ( - (ch>=33 && ch<=60) - || (ch>=62 && ch<=126) - || - ( - (ch==9 || ch==32) - && start+2='!' && ch<='<') + || (ch>='>' && ch<='~') + || ( (ch=='\t' || ch==' ') + && start+2length; else - *new++=*start; + *new++=*start; /* copy char */ ++line; } - else if (ch=='\r' && start+1length; - line=0; - } else - *new++='\n'; - line=0; /*XXX jgh: questionabale indent; probable BUG */ - ++start; + *new++='\n'; /* NL */ + line=0; + ++start; /* consume extra input char */ } else { if (pass==0) dst->length+=3; else - { - sprintf(CS new,"=%02X",ch); + { /* encoded char */ + new += sprintf(CS new,"=%02X",ch); new+=3; } line+=3; diff --git a/src/src/spool_mbox.c b/src/src/spool_mbox.c index 63542ebef..95e71b9c9 100644 --- a/src/src/spool_mbox.c +++ b/src/src/spool_mbox.c @@ -165,7 +165,8 @@ if (!spool_mbox_ok) (void)fclose(mbox_file); mbox_file = NULL; - Ustrncpy(spooled_message_id, message_id, MESSAGE_ID_LENGTH+1); + Ustrncpy(spooled_message_id, message_id, sizeof(spooled_message_id)); + spooled_message_id[sizeof(spooled_message_id)-1] = '\0'; spool_mbox_ok = 1; }