INN commit: trunk (doc/pod/news.pod innd/art.c innd/chan.c innd/rc.c)

INN Commit rra at isc.org
Thu Jul 30 19:13:48 UTC 2009


    Date: Thursday, July 30, 2009 @ 12:13:47
  Author: iulius
Revision: 8555

A wrong source was logged to the news log for local postings,
especially when the local server was not listed in incoming.conf
(RChostname() then returned a wrong static buffer and ARTlog()
also did not handle the case of a local connection).

Also fix the initialization of data->FeedsiteLength when needed.

close #15

Modified:
  trunk/doc/pod/news.pod
  trunk/innd/art.c
  trunk/innd/chan.c
  trunk/innd/rc.c

------------------+
 doc/pod/news.pod |    7 +++++++
 innd/art.c       |   33 +++++++++++++++++++++++++--------
 innd/chan.c      |    3 ++-
 innd/rc.c        |    2 ++
 4 files changed, 36 insertions(+), 9 deletions(-)

Modified: doc/pod/news.pod
===================================================================
--- doc/pod/news.pod	2009-07-29 18:17:40 UTC (rev 8554)
+++ doc/pod/news.pod	2009-07-30 19:13:47 UTC (rev 8555)
@@ -31,6 +31,13 @@
 
 =item *
 
+Fixed the source which is logged to the F<news> log file for local
+postings when the local server is not listed in F<incoming.conf>.
+A wrong name was used, taken amongst known peers.  The source is now
+logged as C<localhost>.
+
+=item *
+
 A new B<-L> flag has been added by Jonathan Kamens to B<makehistory>
 so as to specify a load average limit.  If the system load average exceeds
 the specified limit, B<makehistory> sleeps until it goes below the limit.

Modified: innd/art.c
===================================================================
--- innd/art.c	2009-07-29 18:17:40 UTC (rev 8554)
+++ innd/art.c	2009-07-30 19:13:47 UTC (rev 8555)
@@ -400,23 +400,35 @@
 
     /* Set up the headers that we want to use.  We only need to parse the path
        on rejections if logipaddr is false or we can't find a good host. */
-    if (innconf->logipaddr && cp->Address.ss_family != 0)
-        data->Feedsite = RChostname(cp);
-    else {
+    if (innconf->logipaddr) {
+        if (cp->Address.ss_family != 0) {
+            data->Feedsite = RChostname(cp);
+        } else {
+            data->Feedsite = "localhost";
+        }
+    } else {
         if (HDR_FOUND(HDR__PATH)) {
             HDR_PARSE_START(HDR__PATH);
             hopcount =
                 ARTparsepath(HDR(HDR__PATH), HDR_LEN(HDR__PATH), &data->Path);
             HDR_PARSE_END(HDR__PATH);
             hops = data->Path.List;
-            if (hopcount > 0 && hops != NULL && hops[0] != NULL)
+            if (hopcount > 0 && hops != NULL && hops[0] != NULL) {
                 data->Feedsite = hops[0];
-            else
+            } else {
                 data->Feedsite = "localhost";
-        } else if (cp->Address.ss_family != 0) {
-            data->Feedsite = RChostname(cp);
+            }
+        } else {
+            if (cp->Address.ss_family != 0) {
+                data->Feedsite = RChostname(cp);
+            } else {
+                data->Feedsite = "localhost";
+            }
         }
     }
+
+    data->FeedsiteLength = strlen(data->Feedsite);
+
     ARTlog(data, ART_REJECT, text != NULL ? text : cp->Error);
 
     if (HDR_FOUND(HDR__MESSAGE_ID))
@@ -804,6 +816,7 @@
   data->CurHeader = data->LastCRLF = data->Body = cp->Start;
   data->BytesHeader = NULL;
   data->Feedsite = "?";
+  data->FeedsiteLength = strlen(data->Feedsite);
   *cp->Error = '\0';
 }
 
@@ -1967,7 +1980,11 @@
   /* We have not parsed the Path: header yet.  We do not check for logipaddr
    * right now (it will be done afterwards and change data->Feedsite
    * in consequence).  We assign a feed site for the next call to ARTlog(). */
-  data->Feedsite = RChostname(cp);
+  if (cp->Address.ss_family != 0) {
+    data->Feedsite = RChostname(cp);
+  } else {
+    data->Feedsite = "localhost";
+  }
   if (data->Feedsite == NULL)
     data->Feedsite = CHANname(cp);
   data->FeedsiteLength = strlen(data->Feedsite);

Modified: innd/chan.c
===================================================================
--- innd/chan.c	2009-07-29 18:17:40 UTC (rev 8554)
+++ innd/chan.c	2009-07-30 19:13:47 UTC (rev 8555)
@@ -456,7 +456,8 @@
         snprintf(cp->Name, sizeof(cp->Name), "remconn:%d", cp->fd);
         break;
     case CTreject:
-        snprintf(cp->Name, sizeof(cp->Name), "%s rejected", RChostname(cp));
+        snprintf(cp->Name, sizeof(cp->Name), "%s rejected",
+                 cp->Address.ss_family == 0 ? "localhost" : RChostname(cp));
         break;
     case CTnntp:
         snprintf(cp->Name, sizeof(cp->Name), "%s:%d",

Modified: innd/rc.c
===================================================================
--- innd/rc.c	2009-07-29 18:17:40 UTC (rev 8554)
+++ innd/rc.c	2009-07-30 19:13:47 UTC (rev 8555)
@@ -1675,6 +1675,8 @@
 
 /*
 **  Find the name of a remote host we've connected to.
+**  Note that when cp->Address.ss_family is 0, the connection is local
+**  and the caller should use "localhost".
 */
 char *
 RChostname(const CHANNEL *cp)




More information about the inn-committers mailing list