]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Better handling of contact termend
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Sun, 27 Jul 2025 00:03:37 +0000 (20:03 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Sun, 27 Jul 2025 00:03:37 +0000 (20:03 -0400)
lib/lvleml.c

index 7afbce724499b4ecf4a85592e5be503fc71c9fea..6ddd639000e05e3c803b1817665f78f16eae4807 100644 (file)
 
 static const char *cry="(crypted link is now set in '%s' mode, security level='%d')";
 
+/*
+^L
+*/
+/********************************************************/
+/*                                                      */
+/*     Procedure to update the termination condition   */
+/*      within contact.                                 */
+/*      current session.                                */
+/*                                                      */
+/********************************************************/
+static void setterminator(CONTYP *contact,const char *condition)
+
+{
+if (contact!=(CONTYP *)0) {
+  contact->termend=rou_freestr(contact->termend);
+  contact->termend=strdup(condition);
+  }
+}
 /*
 ^L
 */
@@ -2403,8 +2421,7 @@ while (proceed==true) {
         status=-3;
         break;
       }
-    contact->termend=rou_freestr(contact->termend);
-    contact->termend=strdup(str);
+    (void) setterminator(contact,str);
     //(void) rou_alert(0,"%s exit status='%d'",OPEP,status);
     break;              //no need to go further
 
@@ -2427,8 +2444,7 @@ while (proceed==true) {
       break;
     case c_quit         :       //QUIT SMTP protocol
       contact->credit++;        //clean disconnect
-      contact->termend=rou_freestr(contact->termend);
-      contact->termend=strdup("QUIT received");
+      (void) setterminator(contact,"QUIT received");
       (void) transmit(contact,true,"%d 2.0.0 Bye, closing connection CNT=%s",
                                     QUITOK,contact->mainsesid);
       status=1;                 //every thing fine
@@ -2468,6 +2484,7 @@ while (proceed==true) {
           }
           break;
         case false      :       //unable to establish link
+          (void) setterminator(contact,"starttls not successful");
           (void) transmit(contact,true,"%d 5.3.3 command starttls not successful",
                                         CMDBAD);
           status=-1;