tidying: coverity issues
authorJeremy Harris <jgh146exb@wizmail.org>
Wed, 16 Mar 2016 15:30:57 +0000 (15:30 +0000)
committerJeremy Harris <jgh146exb@wizmail.org>
Wed, 16 Mar 2016 15:32:22 +0000 (15:32 +0000)
src/exim_monitor/em_menu.c
src/src/sieve.c
src/src/spool_mbox.c

index 6975e709dd91f9281d27f705467f800a7842a9db..81df0d37c8aa8f8949550f498e4a795ca933fb9b 100644 (file)
@@ -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";
index bda482fd11238133d77b79acd2eb1686ff830b2c..8f98aebabff039c2a9bb40d981ef37bd7f16dec1 100644 (file)
@@ -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<end; ++start)
     {
     ch=*start;
-    if (line>=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<end
-        && (*(start+1)!='\r' || *(start+2)!='\n')
-        )
-      )
+    if (  (ch>='!' && ch<='<')
+       || (ch>='>' && ch<='~')
+       || (  (ch=='\t' || ch==' ')
+          && start+2<end
+          && (*(start+1)!='\r' || *(start+2)!='\n')    /* CRLF */
+          )
+       )
       {
       if (pass==0)
         ++dst->length;
       else
-        *new++=*start;
+        *new++=*start; /* copy char */
       ++line;
       }
-    else if (ch=='\r' && start+1<end && *(start+1)=='\n')
+    else if (ch=='\r' && start+1<end && *(start+1)=='\n') /* CRLF */
       {
       if (pass==0)
-        {
         ++dst->length;
-        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;
index 63542ebefa53a33b1c3fc1375a0dd3ace011b075..95e71b9c9d324df39c3751caf77b113b28e4883e 100644 (file)
@@ -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;
   }