Make sure rc is initialised
[exim.git] / src / src / smtp_out.c
index 4186b787ad207b9a9b2b00507b8bd38662adc404..d6cfbba7dedf1663e674ba81c5856b4d8f39c0c7 100644 (file)
@@ -1,10 +1,8 @@
-/* $Cambridge: exim/src/src/smtp_out.c,v 1.8 2007/01/08 10:50:18 ph10 Exp $ */
-
 /*************************************************
 *     Exim - an Internet mail transport agent    *
 *************************************************/
 
-/* Copyright (c) University of Cambridge 1995 - 2007 */
+/* Copyright (c) University of Cambridge 1995 - 2009 */
 /* See the file NOTICE for conditions of use and distribution. */
 
 /* A number of functions for driving outgoing SMTP calls. */
@@ -241,7 +239,18 @@ if (save_errno != 0)
 
 else
   {
+  union sockaddr_46 interface_sock;
+  EXIM_SOCKLEN_T size = sizeof(interface_sock);
   HDEBUG(D_transport|D_acl|D_v) debug_printf("connected\n");
+  if (getsockname(sock, (struct sockaddr *)(&interface_sock), &size) == 0)
+    sending_ip_address = host_ntoa(-1, &interface_sock, NULL, &sending_port);
+  else
+    {
+    log_write(0, LOG_MAIN | ((errno == ECONNRESET)? 0 : LOG_PANIC),
+      "getsockname() failed: %s", strerror(errno));
+    close(sock);
+    return -1;
+    }
   if (keepalive) ip_keepalive(sock, host->address, TRUE);
   return sock;
   }
@@ -307,7 +316,7 @@ Returns:     0 if command added to pipelining buffer, with nothing transmitted
 */
 
 int
-smtp_write_command(smtp_outblock *outblock, BOOL noflush, char *format, ...)
+smtp_write_command(smtp_outblock *outblock, BOOL noflush, const char *format, ...)
 {
 int count;
 int rc = 0;