🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.nntp
7 messages
7 total messages Started by Julien ÉLIE Sun, 24 Jul 2011 22:29
Empty folded line in header field (was Re: Censure ?)
#84213
Author: Julien ÉLIE
Date: Sun, 24 Jul 2011 22:29
41 lines
3121 bytes
Hi all,

For those who may be interested:

Date: Sun, 17 Jul 2011 18:51:14 +0200
User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.5; fr; rv:1.9.1.19) Gecko/20110420 Mnenhy/0.8.3 SeaMonkey/2.0.14
Newsgroups: fr.lettres.langues-anciennes.latin
Subject: Re: Censure ?
X-Face: u<)b%~v7<8fL[]Wuuwi1xF$eOV]yWTt-UU6AdQf*1@Djz]J&-5]F}of4|7TL;
   
     "%JRG^C*#<b$:_DkLf#v0}Y-IJ)PG
Message-ID:<4e231311$0$1752$426a74cc@news.free.fr>



The second line of the X-Face: header field is "   \r\n", which is invalid
per RFC 5322:

   3.2.2.  Folding White Space and Comments
 
     There are several places in this specification where comments and FWS
     may be freely inserted.  To accommodate that syntax, an additional
     token for "CFWS" is defined for places where comments and/or FWS can
     occur.  However, where CFWS occurs in this specification, it MUST NOT
     be inserted in such a way that any line of a folded header field is
     made up entirely of WSP characters and nothing else.



It is an example of article that would fail proper distribution.
innd properly relays it.
pullnews does not (it is how I noticed the issue):  it reports "Fixing bad header"
and afterwards fails to detect the message-ID (considered to be in the body of the
message).
Hmm…  nnrpd accepts to inject the article.  Something that needs being changed… :-)

-- 
Julien ÉLIE

« Ce n'est pas en tournant le dos aux choses qu'on leur fait face. »
  (Pierre Dac)
Re: Empty folded line in header field (was Re: Censure ?)
#84214
Author: Shmuel Metz
Date: Mon, 25 Jul 2011 12:02
17 lines
3001 bytes
In <j0i6d5$qt7$1@news.trigofacile.com>, on 07/25/2011
   at 12:29 AM, Julien ÉLIE <iulius@nom-de-mon-site.com.invalid> said:

>Hmm   nnrpd accepts to inject the article.  Something that needs
>being changed  :-)

Why? It is correctly treating the text following the null line as part
of the body.

-- 
Shmuel (Seymour J.) Metz, SysProg and JOAT  <http://patriot.net/~shmuel>

Unsolicited bulk E-mail subject to legal action.  I reserve the
right to publicly post or ridicule any abusive E-mail.  Reply to
domain Patriot dot net user shmuel+news to contact me.  Do not
reply to spamtrap@library.lspace.org
Re: Empty folded line in header field (was Re: Censure ?)
#84247
Author: Florian Schlichting
Date: Tue, 09 Aug 2011 12:39
89 lines
5461 bytes
Hi Julien,

On 2011-07-24, Julien ÉLIE wrote:
> X-Face: u<)b%~v7<8fL[]Wuuwi1xF$eOV]yWTt-UU6AdQf*1@Djz]J&-5]F}of4|7TL;
>    
>      "%JRG^C*#<b$:_DkLf#v0}Y-IJ)PG
> Message-ID:<4e231311$0$1752$426a74cc@news.free.fr>

> The second line of the X-Face: header field is "   \r\n", which is invalid
> per RFC 5322:

> It is an example of article that would fail proper distribution.
> innd properly relays it.
> pullnews does not (it is how I noticed the issue):  it reports "Fixing bad header"
> and afterwards fails to detect the message-ID (considered to be in the body of the
> message).
> Hmm???  nnrpd accepts to inject the article.  Something that needs being changed??? :-)

Both pullnews and nnrpd would be expected to fix the header by cutting
the illegal line, no?

pullnews seems to assume that a header line containing only whitespace
must be a broken transition to the message body, hence it can't find a
Message-ID. I think pullnews could be a little more intelligent about
this and have a look at the following line; if it's in "Headername:
header body" format, or another continuing line starting with
whitespace, then perhaps that can count as a sufficient indicator that
we're still in the header?

Note that the first two chunks of this patch address a different issue
introduced to the 2.5 branch with the INN::Util::Shlock commit; things
seem to be a little different in the trunk branch, but if pullnews is to
be used independently of an INN installation, then perhaps it should not
make use of INN::Util::Shlock at all?

Subject: [PATCH] pullnews: fix all-whitespace header lines

--- a/frontends/Makefile
+++ b/frontends/Makefile
@@ -97,7 +97,7 @@ ovdb_stat.o: ovdb_stat.c
 cnfsheadconf:	cnfsheadconf.in  $(FIX)	; $(FIX) cnfsheadconf.in
 cnfsstat:	cnfsstat.in      $(FIX)	; $(FIX) cnfsstat.in
 mailpost:	mailpost.in      $(FIX)	; $(FIX) mailpost.in
-pullnews:	pullnews.in      $(FIX)	; $(FIX) -i pullnews.in
+pullnews:	pullnews.in      $(FIX)	; $(FIX) pullnews.in
 scanspool:	scanspool.in     $(FIX)	; $(FIX) scanspool.in
 
 bunbatch: Makefile ../Makefile.global
--- a/frontends/pullnews.in
+++ b/frontends/pullnews.in
@@ -1,4 +1,5 @@
 #! /usr/bin/perl -w
+# fixscript will replace this line with code to load INN::Config
 #
 # Author:       James Brister <brister@vix.com> -- berkeley-unix --
 # Start Date:   Sat, 10 Oct 1998 21:40:11 +0200
@@ -720,15 +721,24 @@ sub crossFeedGroup {
                     $xref = 1;
                 }
 
-                # Catch some of the more common problems with articles.
-                if ($article->[$idx] =~ m!^\s+\n$! and $curr_hdr ne 'subject') {
+                # Fix header lines containing only whitespace
+                if ($article->[$idx] =~ m!^\s+\n$!) {
                     print STDERR "Fixing bad header line[$idx]-1: $article->[$idx-1]" if $idx > 0;
                     print STDERR "Fixing bad header line[$idx]::: $article->[$idx]";
                     print STDERR "Fixing bad header line[$idx]+1: $article->[$idx+1]";
-                    # Do not use $line_len here because $article->[$idx] has been modified
-                    # since the length was computed.
-                    $tx_len -= length($article->[$idx]) - 1;
-                    $article->[$idx] = "\n";
+                    # try to guess if next line is still a header or beginning of body
+                    if ($article->[$idx+1] =~ /^\S+:/ or $article->[$idx+1] =~ /^\s+\S/) {
+                        print STDERR "\tCUTTING illegal empty header line[$idx]\n";
+                        # Do not use $line_len here because $article->[$idx] has been modified
+                        # since the length was computed.
+                        $tx_len -= length($article->[$idx]);
+                        splice @$article, $idx, 1;
+                        $idx--;
+                    } else {
+                        print STDERR "\tFORCING body at line[$idx]\n";
+                        $tx_len -= length($article->[$idx]) - 1;
+                        $article->[$idx] = "\n";
+                    }
                 }
 
                 $headers = 0 if $article->[$idx] eq "\n";

Florian
Re: Empty folded line in header field (was Re: Censure ?)
#84248
Author: Joshua Cranmer
Date: Tue, 09 Aug 2011 15:06
11 lines
2068 bytes
On 7/24/2011 5:29 PM, Julien ÉLIE wrote:
> The second line of the X-Face: header field is "   \r\n", which is invalid
> per RFC 5322:

Even though it is invalid for FWS, it is part of the obs-FWS construct
[it was part of RFC 822 IIRC], so a conforming RFC 5322 agent must not
emit such a line but it must still accept a message containing that line.

-- 
Beware of bugs in the above code; I have only proved it correct, not 
tried it. -- Donald E. Knuth
Re: Empty folded line in header field (was Re: Censure ?)
#84250
Author: Julien ÉLIE
Date: Tue, 09 Aug 2011 17:34
101 lines
5242 bytes
Hi Florian,

>> Hmm... nnrpd accepts to inject the article. Something that needs
>> being changed... :-)
>
> Both pullnews and nnrpd would be expected to fix the header by
> cutting the illegal line, no?

pullnews is considered as a relaying agent here.

According to RFC 5537:

3.6.  Duties of a Relaying Agent

    Relaying agents MUST NOT alter, delete, or rearrange any part of an
    article except for the Path and Xref header fields.  They MUST NOT
    modify the body of articles in any way.  If an article is not
    acceptable as is, the article MUST be rejected rather than modified.



As for nnrpd:

3.5.  Duties of an Injecting Agent

    2.   It MUST reject any proto-article that does not have the proper
         mandatory header fields for a proto-article, that has Injection-
         Info or Xref header fields, that has a Path header field
         containing the "POSTED" <diag-keyword>, or that is not
         syntactically valid as defined by [RFC5536].



So, NO, they are not expected to fix anything.




> pullnews seems to assume that a header line containing only whitespace
> must be a broken transition to the message body, hence it can't find a
> Message-ID. I think pullnews could be a little more intelligent about
> this and have a look at the following line; if it's in "Headername:
> header body" format, or another continuing line starting with
> whitespace, then perhaps that can count as a sufficient indicator that
> we're still in the header?

Yes, I agree with you.  Please note that it is not really a bug because 
pullnews follows this MAY:

3.6.  Duties of a Relaying Agent

    4.  It SHOULD reject any article that does not include all the
        mandatory header fields.  It MAY reject any article that contains
        header fields that do not have valid contents.


However, I would tend not to follow this MAY.  I reckon that the best 
thing to do is to accept the article with the parsing you suggest, and 
relay it without any modification.
innd already relays it correctly (without modification).




> Note that the first two chunks of this patch address a different issue
> introduced to the 2.5 branch with the INN::Util::Shlock commit; things
> seem to be a little different in the trunk branch

Oh, many thanks Florian!

It is true that commit 9100 is for INN 2.6.0 only, and shared (but only 
later) a common bit with INN 2.5.3 for the use of INN::Config and 
INN::Utils::Shlock packages.
     http://inn.eyrie.org/trac/changeset/9100

Now fixed.



> but if pullnews is to
> be used independently of an INN installation, then perhaps it should not
> make use of INN::Utils::Shlock at all?

As pullnews is currently shipped with INN and, as far as I know, is not 
released in another package elsewhere, I think we can go on improving 
the script and using INN::Utils::Shlock; we may want to reconsider it in 
case somebody steps up and wants to maintain the script out of the INN 
tar ball.  It is for instance what is done with pgpverify or signcontrol.
However, without the use of shlock(), there is a portability issue. 
Dennis reported that pullnews does not work on Solaris.

So a fix, in case pullnews should not refer to INN packages, would be to 
use LockFile::Simple (when INN::Utils::Shlock is not loadable).  A 
supplementary dependency.
Or of course still use flock(), but it is not available on every system.

-- 
Julien ÉLIE

« C'est souvent la femme qui nous inspire les grandes choses qu'elles
   nous empêchent d'accomplir. » (Alexandre Dumas Fils)
Re: Empty folded line in header field (was Re: Censure ?)
#84253
Author: Florian Schlichting
Date: Tue, 09 Aug 2011 21:15
102 lines
5610 bytes
Hi Julien,

>> Both pullnews and nnrpd would be expected to fix the header by
>> cutting the illegal line, no?
>
> pullnews is considered as a relaying agent here.

> 3.5.  Duties of an Injecting Agent
>
>     2.   It MUST reject any proto-article that does not have the proper
>          mandatory header fields for a proto-article, that has Injection-
>          Info or Xref header fields, that has a Path header field
>          containing the "POSTED" <diag-keyword>, or that is not
>          syntactically valid as defined by [RFC5536].
>
> So, NO, they are not expected to fix anything.

Ah, I see, not even as Injecting Agent... In that case, the whole
paragraph / if-clause ("Catch some of the more common problems...")
should probably be deleted, because all it does is "fix" a header line
that would otherwise render the article syntactically invalid that ought
to be rejected? But I think the waters are a bit muddy here with
pullnews' -H option that will just remove arbitrary headers...

>> pullnews seems to assume that a header line containing only whitespace
>> must be a broken transition to the message body, hence it can't find a
>> Message-ID. I think pullnews could be a little more intelligent about
>> this and have a look at the following line; if it's in "Headername:
>> header body" format, or another continuing line starting with
>> whitespace, then perhaps that can count as a sufficient indicator that
>> we're still in the header?
>
> Yes, I agree with you.  Please note that it is not really a bug because 
> pullnews follows this MAY:
>
> 3.6.  Duties of a Relaying Agent
>
>     4.  It SHOULD reject any article that does not include all the
>         mandatory header fields.  It MAY reject any article that contains
>         header fields that do not have valid contents.
>
>
> However, I would tend not to follow this MAY.  I reckon that the best 
> thing to do is to accept the article with the parsing you suggest, and 
> relay it without any modification.

If nothing in the article is going to be modified, no parsing needs to
be done in pullnews (the whole if-clause is unnecessary); and it is then
up to the daemon that pullnews feeds its articles to to decide whether
to accept (innd) or reject (nnrpd) the article. Makes sense?


>> Note that the first two chunks of this patch address a different issue
>> introduced to the 2.5 branch with the INN::Util::Shlock commit; things
>> seem to be a little different in the trunk branch
>
> Oh, many thanks Florian!
>
> It is true that commit 9100 is for INN 2.6.0 only, and shared (but only 
> later) a common bit with INN 2.5.3 for the use of INN::Config and 
> INN::Utils::Shlock packages.
>      http://inn.eyrie.org/trac/changeset/9100
>
> Now fixed.

I am not sure...

The first three lines of pullnews.in are:

#! /usr/bin/perl -w
# use lib '@LIBPERLDIR@'; use INN::Config;
# If running inside INN, uncomment the above and point to INN::Config.

Running 'perl -wc pullnews.in' will tell you it "Can't locate
INN/Utils/Shlock.pm in @INC" - so it clearly cannot stay that way, and
it cannot be used independently from INN unaltered.

Now the makefile for both trunk and now also 2.5 runs 'fixscript
pullnews.in' (without -i), so the first three lines of the pullnews that
gets installed are:

#! /usr/bin/perl -w
use lib '/path/to/INN/lib/perl'; use INN::Config;
# If running inside INN, uncomment the above and point to INN::Config.

This helps with finding Shlock.pm, but the third line is bogus and the
change is not what one would expect from looking at the source of
pullnews.in - which is why I suggest changing those lines to the usual
sentence about fixscript, and perhaps a blank line.

> As pullnews is currently shipped with INN and, as far as I know, is not 
> released in another package elsewhere, I think we can go on improving 
> the script and using INN::Utils::Shlock; we may want to reconsider it in 
> case somebody steps up and wants to maintain the script out of the INN 
> tar ball.  It is for instance what is done with pgpverify or signcontrol.
> However, without the use of shlock(), there is a portability issue. 

I'm all with you here, particularly since using pullnews will in most
cases involve maintaining a news server as well. This may be different
for e.g. signcontrol, which can be useful for non-admins, too.

Florian
Re: Empty folded line in header field (was Re: Censure ?)
#84254
Author: Julien ÉLIE
Date: Tue, 09 Aug 2011 22:49
66 lines
3850 bytes
Hi Florian,

>the whole
> paragraph / if-clause ("Catch some of the more common problems...")
> should probably be deleted, because all it does is "fix" a header line
> that would otherwise render the article syntactically invalid that ought
> to be rejected?

Yes, I agree that the whole clause should be deleted.



> But I think the waters are a bit muddy here with
> pullnews' -H option that will just remove arbitrary headers...

There is no problem with that because it is not the default behaviour of 
pullnews.  If a news administrator wants to change things, it is up to 
him.  He normally uses special flags consciously...



> If nothing in the article is going to be modified, no parsing needs to
> be done in pullnews (the whole if-clause is unnecessary); and it is then
> up to the daemon that pullnews feeds its articles to to decide whether
> to accept (innd) or reject (nnrpd) the article. Makes sense?

Yes, I think it makes sense.
"pullnews -R" can be used to force nnrpd.  By default, pullnews uses 
IHAVE so it works well with innd (and nnrpd if IHAVE is allowed in 
readers.conf).



>>> Note that the first two chunks of this patch address a different issue
>>> introduced to the 2.5 branch with the INN::Util::Shlock commit; things
>>> seem to be a little different in the trunk branch
>>
>> Now fixed.
>
> I am not sure...
>
> The first three lines of pullnews.in are:
>
> #! /usr/bin/perl -w
> # use lib '@LIBPERLDIR@'; use INN::Config;
> # If running inside INN, uncomment the above and point to INN::Config.
>
> Running 'perl -wc pullnews.in' will tell you it "Can't locate
> INN/Utils/Shlock.pm in @INC" - so it clearly cannot stay that way, and
> it cannot be used independently from INN unaltered.

Ah, OK, I understand your point.
I will then remove the third line.



> I'm all with you here, particularly since using pullnews will in most
> cases involve maintaining a news server as well. This may be different
> for e.g. signcontrol, which can be useful for non-admins, too.

That's a good point, yes.

-- 
Julien ÉLIE

« Sitis licita, etiam potio licita. »
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads