🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.nntp
12 messages
12 total messages Started by newone Wed, 08 Apr 2015 02:02
NNTP article headers sequence
#86507
Author: newone
Date: Wed, 08 Apr 2015 02:02
20 lines
1401 bytes
Hello.

I've looked at my news spool and noticed that headers in all articles 
are in sequence:

Path:
From:
Newsgroups:
Subject:
Date:
Organization:
Message-ID:

I would like to write my own little newsserver software, but I can't 
find any information about headers sequence in RFC. Is that sequence 
mandatory? If I'm sending out articles with headers out of sequence, 
will other servers accept them?

Thank you.
Re: NNTP article headers sequence
#86508
Author: Russ Allbery
Date: Wed, 08 Apr 2015 02:48
28 lines
1695 bytes
newone <newone@example.tld> writes:

> I've looked at my news spool and noticed that headers in all articles are
> in sequence:

> Path:
> From:
> Newsgroups:
> Subject:
> Date:
> Organization:
> Message-ID:

> I would like to write my own little newsserver software, but I can't find
> any information about headers sequence in RFC. Is that sequence mandatory?

No.  Headers can be in any order.

> If I'm sending out articles with headers out of sequence, will other
> servers accept them?

Yes.

-- 
Russ Allbery (eagle@eyrie.org)              <http://www.eyrie.org/~eagle/>

          Please post questions rather than mailing me directly.
     <http://www.eyrie.org/~eagle/faqs/questions.html> explains why.
Re: NNTP article headers sequence
#86509
Author: newone
Date: Wed, 08 Apr 2015 03:25
28 lines
1699 bytes
On 2015-04-08 02:48:18 +0000, Russ Allbery said:

> newone <newone@example.tld> writes:
> 
>> I've looked at my news spool and noticed that headers in all articles are
>> in sequence:
> 
>> Path:
>> From:
>> Newsgroups:
>> Subject:
>> Date:
>> Organization:
>> Message-ID:
> 
>> I would like to write my own little newsserver software, but I can't find
>> any information about headers sequence in RFC. Is that sequence mandatory?
> 
> No.  Headers can be in any order.
> 
>> If I'm sending out articles with headers out of sequence, will other
>> servers accept them?
> 
> Yes.

Thank you. One more question. If it is not mandatory, why INN always 
groups headers in that sequence?
Re: NNTP article headers sequence
#86510
Author: Russ Allbery
Date: Wed, 08 Apr 2015 04:47
14 lines
1579 bytes
newone <newone@example.tld> writes:

> Thank you. One more question. If it is not mandatory, why INN always
> groups headers in that sequence?

It's an artifact of how headers are represented in the internal data
structures used by nnrpd, which I think has been there since the very
early days of INN.  Maybe all the way back to 1.0.

-- 
Russ Allbery (eagle@eyrie.org)              <http://www.eyrie.org/~eagle/>

          Please post questions rather than mailing me directly.
     <http://www.eyrie.org/~eagle/faqs/questions.html> explains why.
Re: NNTP article headers sequence
#86511
Author: Michael Baeuerle
Date: Wed, 08 Apr 2015 10:31
9 lines
1476 bytes
newone wrote:
> 
> I would like to write my own little newsserver software, but I can't 
> find any information about headers sequence in RFC. [...]

For completeness:
The document that allows arbitrary order of header fields is RFC5322
(referenced by RFC5536):
<http://tools.ietf.org/html/rfc5322#section-3.6>
Re: NNTP article headers sequence
#86512
Author: Doc O'Leary
Date: Wed, 08 Apr 2015 14:22
14 lines
1622 bytes
For your reference, records indicate that 
newone <newone@example.tld> wrote:

> If it is not mandatory, why INN always 
> groups headers in that sequence?

Were you planning to write your own software so that it didn’t always
put headers in the same sequence?  Why?

-- 
"Also . . . I can kill you with my brain."
River Tam, Trash, Firefly

Re: NNTP article headers sequence
#86514
Author: newone
Date: Wed, 08 Apr 2015 20:54
15 lines
1571 bytes
On 2015-04-08 14:22:32 +0000, Doc O'Leary said:

> For your reference, records indicate that
> newone <newone@example.tld> wrote:
> 
>> If it is not mandatory, why INN always
>> groups headers in that sequence?
> 
> Were you planning to write your own software so that it didn’t always
> put headers in the same sequence?  Why?

Because I would like to deal with them as with hash. Once I'm done, 
I'll join hash to array of bytes using CR/LF characters. This does not 
guarantee any particular sequence in which string will be joined.
Re: NNTP article headers sequence
#86516
Author: Doc O'Leary
Date: Thu, 09 Apr 2015 02:35
18 lines
2096 bytes
For your reference, records indicate that 
newone <newone@example.tld> wrote:

> Because I would like to deal with them as with hash. Once I'm done, 
> I'll join hash to array of bytes using CR/LF characters. This does not 
> guarantee any particular sequence in which string will be joined.

It might not be “guaranteed”, but I think you’ll find that the
implementation of most hash tables is generally going to return keys in
the same order for any hash that had all the same keys inserted in the
same order.  I certainly see that for NSDictionary (which is what you
also might possibly intend to use based on your User-Agent).

-- 
"Also . . . I can kill you with my brain."
River Tam, Trash, Firefly

Re: NNTP article headers sequence
#86517
Author: newone
Date: Thu, 09 Apr 2015 02:50
21 lines
1977 bytes
On 2015-04-09 02:35:02 +0000, Doc O'Leary said:

> For your reference, records indicate that
> newone <newone@example.tld> wrote:
> 
>> Because I would like to deal with them as with hash. Once I'm done,
>> I'll join hash to array of bytes using CR/LF characters. This does not
>> guarantee any particular sequence in which string will be joined.
> 
> It might not be “guaranteed”, but I think you’ll find that the
> implementation of most hash tables is generally going to return keys in
> the same order for any hash that had all the same keys inserted in the
> same order.  I certainly see that for NSDictionary (which is what you
> also might possibly intend to use based on your User-Agent).

Thanks for pointing it out.

Since there are no any mandatory sequence, it does not really matter, 
as long as other servers will accept resulting headers without me doing 
any sorting before sending articles to them.
Re: NNTP article headers sequence
#86518
Author: Russ Allbery
Date: Thu, 09 Apr 2015 03:57
24 lines
2394 bytes
Doc O'Leary  <droleary@2usenet2014.subsume.com> writes:

> It might not be “guaranteed”, but I think you’ll find that the
> implementation of most hash tables is generally going to return keys in
> the same order for any hash that had all the same keys inserted in the
> same order.

That used to be the case, and then security researchers uncovered a lot of
interesting denial of service attacks that can be launched against any
program that has that property.  (The short version is that hashing
algorithms always have distribution issues, and if you know what keys that
algorithm has trouble with and some control over what's being hashed, you
can reduce a lot of hashes to effectively a linked list.)

As a result, at least most scripting languages (Perl, Python, PHP, etc.)
have implemented hash randomization, so you'll now get keys out in a
different order each time you run the program.  Good hash libraries are
likely to follow suite for the same reason.

-- 
Russ Allbery (eagle@eyrie.org)              <http://www.eyrie.org/~eagle/>

          Please post questions rather than mailing me directly.
     <http://www.eyrie.org/~eagle/faqs/questions.html> explains why.
Re: NNTP article headers sequence
#86519
Author: Doc O'Leary
Date: Thu, 09 Apr 2015 15:10
28 lines
2743 bytes
For your reference, records indicate that 
Russ Allbery <eagle@eyrie.org> wrote:

> Doc O'Leary  <droleary@2usenet2014.subsume.com> writes:
> 
> > It might not be “guaranteed”, but I think you’ll find that the
> > implementation of most hash tables is generally going to return keys in
> > the same order for any hash that had all the same keys inserted in the
> > same order.
> 
> That used to be the case, and then security researchers uncovered a lot of
> interesting denial of service attacks that can be launched against any
> program that has that property.  (The short version is that hashing
> algorithms always have distribution issues, and if you know what keys that
> algorithm has trouble with and some control over what's being hashed, you
> can reduce a lot of hashes to effectively a linked list.)

I did not know that; thanks for the correction.  I’d expect a good hash
library that implements that (universal hashing) to also preserve key
order externally (assuming it was deterministic in previous versions)
for maximum backward compatibility, though.  Regardless, I guess I’m
going to have to look into sorting any key arrays I use, just in case.

-- 
"Also . . . I can kill you with my brain."
River Tam, Trash, Firefly

Re: NNTP article headers sequence
#86520
Author: Russ Allbery
Date: Thu, 09 Apr 2015 19:45
17 lines
2176 bytes
Doc O'Leary  <droleary@2usenet2014.subsume.com> writes:

> I did not know that; thanks for the correction.  I’d expect a good hash
> library that implements that (universal hashing) to also preserve key
> order externally (assuming it was deterministic in previous versions)
> for maximum backward compatibility, though.

There's basically no good way to fix the bug without breaking backward
compatibility, or at least Perl, Python, and PHP didn't find one and went
ahead and broke it.  We were fixing bad Perl tests that implicitly assumed
hash ordering for months and years afterwards.

-- 
Russ Allbery (eagle@eyrie.org)              <http://www.eyrie.org/~eagle/>

          Please post questions rather than mailing me directly.
     <http://www.eyrie.org/~eagle/faqs/questions.html> explains why.
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