From aab@cichlid.com Thu Dec 12 14:13:35 EST 1996
Article: 27684 of news.software.nntp
Path: news.math.psu.edu!scramble.lm.com!news.psc.edu!nntp.sei.cmu.edu!fs7.ece.cmu.edu!cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!cam-news-feed3.bbnplanet.com!cam-news-hub1.bbnplanet.com!news.bbnplanet.com!su-news-hub1.bbnplanet.com!arclight.uoregon.edu!news.bc.net!info.ucla.edu!news.ucdavis.edu!news.cichlid.com!news.cichlid.com!not-for-mail
From: aab@cichlid.com (Andy Burgess)
Newsgroups: news.software.nntp
Subject: FIX: Re: INN 1.5 VS 1.5b2, perl filtering trouble
Date: 11 Dec 1996 13:39:46 -0800
Lines: 108
Distribution: inet
Message-ID: <58n9n2$lfr$1@loach.cichlid.com>
References: <58k1l2$vs4$1@loach.cichlid.com>
NNTP-Posting-Host: loach.cichlid.com
Xref: news.math.psu.edu news.software.nntp:27684

In <58k1l2$vs4$1@loach.cichlid.com> aab@cichlid.com (Andy Burgess) writes:

>I have been attempting to upgrade from INN 1.5b2 to 1.5. Both versions
>use almost the same config.data, exactly the same perl (5.003) and 
>filter_innd.pl (config diff at the end of this post). I switch between
>versions by running make update in the appropriate directories).

This was caused by the perl memory leak fixes in 1.5.

The perl lib macro FREETMPS frees the return value from the perl
function filter_art. The value was returned from HandleArticle() in
perl.c, a classic using memory after freeing it bug.  The following
patch fixes this.

This was causing intermittant garbage returns from filter_art and thus
garbage reasons for rejection in the log file, eg:

innd: rejecting[perl] <961209210445_708138071@emout19.mail.aol.com> 437 xH
Dec  9 18:14:16.377 - news.scruz.net <961209210445_708138071@emout19.mail.aol.co
m> 437 xH

There is another bug which I haven't fixed yet whereby optional article
headers are not cleared from the perl hdr array. Thus when you get a
header with a Control line, the hdr array has the same control line
value for all subsequent articles in the perl program that do not have
Control header lines.  This can be worked around in the perl code by
including the following line in filter_art after you are finished with
the hdr array:

$hdr{"Control"} = "";

I don't know how to fix this in perl.c without leaking memory but its
just a perl manpage read away.

Thanks to everyone who ever worked on inn :-)

========================================================================

*** perl.c.orig	Wed Dec 11 12:49:04 1996
--- perl.c	Wed Dec 11 13:14:56 1996
***************
*** 39,45 ****
     ARTHEADER	*hp;
     HV		*hdr;
     int		rc;
!    char		*p;
  
     if (!PerlFilterActive || perl_filter_cv == NULL)
       return NULL;
--- 39,46 ----
     ARTHEADER	*hp;
     HV		*hdr;
     int		rc;
!    char		*p = NULL; /* may not get set below */
!    static char	buf[200];
  
     if (!PerlFilterActive || perl_filter_cv == NULL)
       return NULL;
***************
*** 46,51 ****
--- 47,55 ----
  
     /* Create the Perl Hash */
     hdr = perl_get_hv("hdr", TRUE);
+ 
+    /* fix the Control header not being reset bug */
+    /* hv_store(hdr, "Control", sizeof("Control"), ... */
     for (hp = ARTheaders; hp < ARTheadersENDOF; hp++)
       {
         if (hp->Found && hp->Value)
***************
*** 70,82 ****
       {
       p = POPp;
     }
  
     PUTBACK;
     FREETMPS;
     LEAVE;
  
!    if (p != NULL && *p != '\0')
!       return p;
     return NULL;
  }
  
--- 74,93 ----
       {
       p = POPp;
     }
+    if(p != NULL && *p != '\0') 
+      {
+      strncpy(buf, p, sizeof(buf)-1);
+      buf[sizeof(buf)-1] = '\0';
+      } 
+    else
+      *buf = '\0';
  
     PUTBACK;
     FREETMPS;
     LEAVE;
  
!    if (*buf != '\0')
!       return buf;
     return NULL;
  }
  




