Subject: Re: Unexpected EOF in 7.2.0

From: John Goerzen <[email-masked]>
Date: Fri, 09 Jul 2021 15:23:05 -0500

I think I have a lead on this.

The packet was generated on a Raspberry Pi (32-bit ARM userland), 
is 3GB in size, and is being processed on an x86_64 machine 
(64-bit userland).

I added some debug info to pkt.go, and this was printed when -dump 
was used:

pktEncRead: Making LimitedReader, size: -1097891139
readBytes: 0, len(buf): 131088, len(toRead): 131088, EnbClkSize: 
131072, aead.Overhead: 16, doEncrypt %!d(bool=false)
main.go:163: unexpected EOF

So the presence of that LimitedReader looks to me like what caused 
the UnexpectedEof...  and if it's being called with a negative 
size, that could particularly cause it.

I did try decoding this packet on the Raspberry Pi, but got the 
same result.

Attached is the modified pkt.go that produced this output.

Hope this helps!  Hopefully whatever the issue is in nncp-pkt also 
leads to the issue in nncp-toss.

- John

On Fri, Jul 09 2021, John Goerzen wrote:

> I'm fairly baffled by this.  I ran it under strace, and there's 
> no syscall
> that's returning EOF.  nncp-pkt is easier to analyze under 
> strace, and it does a
> 4096-byte read, gets a 4096-byte result, then crashes with 
> unexpected EOF.
>
> I don't know Go, though...  I'm also baffled at how the test at 
> pkt.go line 163
> could cause an error.
>
> - John
>
> On Fri, Jul 09 2021, John Goerzen wrote:
>
>> Hello,
>>
>> I have a 3GB packet that was transferred from its origin to my 
>> gateway machine
>> via nncp-call.  When called on it, nncp-check works fine and 
>> verifies its
>> integrity.  However:
>>
>> nncp@nncp:~$ nncp-toss -progress
>> 2021-07-09T15:10:27Z ERROR Tossing
>> mccoy/74HUFHYZOB7J7MLU7SHKTRODN7OH7HRLSSTKWEEDKNMXLOJBDI2Q:
>> unmarshal: xdr:DecodeFixedOpaque: unexpected EOF while decoding 
>> 8 bytes -
>> read:
>> '[]'
>>
>> And the log shows:
>>
>> When: 2021-07-09T15:12:13.896311727Z
>> Err: xdr:DecodeFixedOpaque: unexpected EOF while decoding 8 
>> bytes - read: '[]'
>> Who: rx-unmarshal
>> Node: NE2CD32WK62N3QWWQLJUZXVX2WZAIMM7DBIXQVJTFDSXHAWSULBQ
>> Pkt: 74HUFHYZOB7J7MLU7SHKTRODN7OH7HRLSSTKWEEDKNMXLOJBDI2Q
>> Nice: 226
>> Msg: Tossing 
>> mccoy/74HUFHYZOB7J7MLU7SHKTRODN7OH7HRLSSTKWEEDKNMXLOJBDI2Q:
>> unmarshal
>>
>> (this is a transitional packet)
>>
>> Also:
>>
>> nncp@nncp:~$ nncp-pkt -dump <
>> /var/spool/nncp/NE2CD32WK62N3QWWQLJUZXVX2WZAIMM7DBIXQVJTFDSXHAWSULBQ/rx/74HUFHYZOB7J7MLU7SHKTRODN7OH7HRLSSTKWEEDKNMXLOJBDI2Q
>> main.go:163: unexpected EOF
>>
>> These commands that return with "unexpected EOF" are returning 
>> almost
>> immediately.  They could not possibly have processed 3GB like 
>> nncp-check does.
>> If I omit -dump from nncp-pkt, it works fine.  I tried 
>> reblocking with dd, and
>> that didn't help either.
>>
>> This occurs both with go 1.14 and go 1.15.
>>
>> The only unique thing here is that it's from a new node on my 
>> network.
>>
>> Other packets from that node were processed successfully, 
>> though they were
>> much
>> smaller.  I tried removing the .hdr file and that didn't help 
>> either (it was
>> recreated).
>>
>> Thanks!
>>
>> - John