πŸš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #82722

Re: unrelated possible bug with C flag?

#82722
From: D. Stussy
Date: Sun, 31 Jan 2010 23:44
106 lines
6237 bytes
"Julien Γ‰LIE" <iulius@nom-de-mon-site.com.invalid> wrote in message
news:hk3jns$rf1$1@news.trigofacile.com...
> >> Then the (complete) patch is the following:
> >
> > Your patch is still wrong.  From the loop, variable "i" should be able
to
> > assume the value of zero if the data field of the "Followup-To:" header
is
> > empty or not specified.
>
> Gosh!  I still do not understand at all your position on that subject.

The SOLE purpose of this routine snippet is to count followup groups.  Such
is post-acceptance processing of an article for distribution to peers.

What I keep questioning is why you try to do syntax checking on an
already-accepted article.

> When I suggest a patch that finds out 0 for "Followup-To:   ,  "
> or  "Followup-To:   ,  , " you disagree because I should not check the
> syntax and you tell me the article is bad and should not have been
> injected.
> So I changed the patch not to properly parse that syntax and find the
> real number of newsgroups.
>
> And now, you tell me that the patch is wrong and should find out 0 for
> "Followup-To:     ", that is to say an EMPTY header field.

Why not?  How many groups do you see there?  I see ZERO.

> Yet, RFC 5536 explicitly states:
>
>    o  Every line of a header field body (including the first and any
>       that are subsequently folded) MUST contain at least one non-
>       whitespace character.
>
> So you *do* want to check the syntax here.

Completely WRONG.  I do NOT want to check syntax here because INN has
ALREADY ACCEPTED the article, and as such, I assume that it is already
syntactically correct.  Syntax checking should be performed BEFORE article
acceptance.

> > Look at my solution.  It accounts for that possibility.
>
> I do not understand why you want to explicitly account for that
> possibility and not all the others.  You usually tell me the article
> should not have been injected in the system and is bad...

Because it has different treatment: NOT having a "Followup-To:" header (or
the header with empty data) is equivalent to using the "Newsgroups:" header
in its place.  As we've already parsed and counted the groups, we simply
copy that result into the followup count.

> Last but not least, if I look at your solution:
>
>   if (HDR_FOUND(HDR__FOLLOWUPTO)) {
>     for (i = 0, p = HDR(HDR__FOLLOWUPTO) ; p != NULL ; i++)
>         p = strchr( ++p, ',');
>   [...]
>
> it does not work the way you say it works.
> i++ is executed at the end of the expression so you will have i=1
> for an empty header field body.

No, I won't - because P == NULL on the first conditional check.  The HDR
routine should be returning a whitespace-trimmed copy of the header data.
The single space following the colon is NOT part of the data field but part
of the field separator from the header name.  The syntax says _header_name_
": " _header_data_ - that is:  NAME  COLON  SPACE  DATA.

Results:
Header not present ->  i=0;  [HDR() = NULL]
Header empty -> i=0 [HDR() = NULL]
Header has no commas -> i=1  [HDR() != NULL]
Header with commas -> i = #_of_commas + 1  [HDR() != NULL]

Such is exactly the result we want.

"Poster" with its special meaning occurs ONLY when i = 1.  It cannot occur
with i=0.  Should it occur with i >=2, then we have a syntax error that
should have caused rejection of the article; therefore, it never reaches
the above code and we need not consider it.

> In fact, the code you suggest is exactly the same as the one we
> already had except for the fact that it adds the possibility of
> a read beyond our allocated memory (look at your ++p if *p is '\0'
> for an empty header field -- the variable might be set to an empty
> string if the header exists and is empty).

It's more correct than what you offered, as you compute the wrong value of
"i" for at least one case.

How can *p =0?  Only if we have "...," (a comma at the end of the string) -
a syntax error, so it will never occur since we will not reach this point
with a rejected article.

> Note that I have not checked whether the variable can actually have
> this "\0" value.  Maybe it is not set at all (NULL) so the code
> would here be fine.  But it is better not to use ++p to prevent
> the code from breaking in the future.

Why?  If the comma is found, we KNOW that the next character is NOT the end
of the string (because, if it were, the article would have been rejected).

Technical Details
Message-ID: <hk54ko$akg$1@snarked.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.20141118.mbox.gz!border1.nntp.ams.giganews.com!nntp.giganews.com!news.k-dsl.de!news.snarked.org!not-for-mail
References: <hic74m$vi8$1@news.trigofacile.com> <hicf9f$ntj$1@snarked.org> <hiclo9$dd4$1@news.trigofacile.com> <hidmvp$vh1$1@snarked.org> <hitipd$rtb$1@news.trigofacile.com> <hiu2ar$707$1@snarked.org> <hiun2p$2mt$1@news.trigofacile.com> <hj0m9c$g98$1@snarked.org> <hj7qh0$ggu$1@news.trigofacile.com> <hj8csn$cok$1@snarked.org> <hjaiid$f7c$1@news.trigofacile.com> <hjar9t$mq$1@snarked.org> <hjnpm4$f5l$1@news.trigofacile.com> <hjq8r4$s5h$1@news.trigofacile.com> <hjqp78$iis$1@snarked.org> <hjsinn$cst$1@news.trigofacile.com> <hjsvgf$vko$1@snarked.org> <hjt1a2$u54$1@news.trigofacile.com> <hjt36j$1m8$2@snarked.org> <hjt45t$167$1@news.trigofacile.com> <hk002q$lni$1@snarked.org> <hk23qr$dok$1@news.trigofacile.com> <hk3cgr$662$1@snarked.org> <hk3jns$rf1$1@news.trigofacile.com>

Show Full Headers
Complete Article Headers
Message-ID: <hk54ko$akg$1@snarked.org>
Subject: Re: unrelated possible bug with C flag?
Date: Sun, 31 Jan 2010 15:44:05 -0800
From: "D. Stussy" <spam+newsgroups@bde-arc.ampr.org>
References: <hic74m$vi8$1@news.trigofacile.com> <hicf9f$ntj$1@snarked.org> <hiclo9$dd4$1@news.trigofacile.com> <hidmvp$vh1$1@snarked.org> <hitipd$rtb$1@news.trigofacile.com> <hiu2ar$707$1@snarked.org> <hiun2p$2mt$1@news.trigofacile.com> <hj0m9c$g98$1@snarked.org> <hj7qh0$ggu$1@news.trigofacile.com> <hj8csn$cok$1@snarked.org> <hjaiid$f7c$1@news.trigofacile.com> <hjar9t$mq$1@snarked.org> <hjnpm4$f5l$1@news.trigofacile.com> <hjq8r4$s5h$1@news.trigofacile.com> <hjqp78$iis$1@snarked.org> <hjsinn$cst$1@news.trigofacile.com> <hjsvgf$vko$1@snarked.org> <hjt1a2$u54$1@news.trigofacile.com> <hjt36j$1m8$2@snarked.org> <hjt45t$167$1@news.trigofacile.com> <hk002q$lni$1@snarked.org> <hk23qr$dok$1@news.trigofacile.com> <hk3cgr$662$1@snarked.org> <hk3jns$rf1$1@news.trigofacile.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.20141118.mbox.gz!border1.nntp.ams.giganews.com!nntp.giganews.com!news.k-dsl.de!news.snarked.org!not-for-mail
Newsgroups: news.software.nntp
Lines: 106
Reply-To: "D. Stussy" <replies@newsgroups.kd6lvw.ampr.org>
NNTP-Posting-Host: 71.118.51.220
X-Trace: snarked.org 1264981464 10896 71.118.51.220 (31 Jan 2010 23:44:24 GMT)
X-Complaints-To: newsmaster+complaints@snarked.org
NNTP-Posting-Date: Sun, 31 Jan 2010 23:44:24 +0000 (UTC)
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1478
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1478