Open mhite opened 1 year ago
I think the default buffer is 4096.
https://cs.opensource.google/go/go/+/master:src/bufio/bufio.go;l=19
Math adds up. I added some more info to the error message so we could see what .Buffered()
equals.
err = readBlob: invalid blob length 11520, Buffered() == 4020
4020 + 76 bytes (see previous comment about the 76 byte present before the blob) = 4096.
I am hitting an interesting error when parsing a binary blob.
Here's the code of interest:
Specifically:
I am wondering
reader.Buffered()
is really returning the full length as expected.For context, here's some debug logs I have from my application.
The number of bytes in the token output you see above that appear before the blob is 76 bytes. The length of the token is 11596 (including those 76 bytes).
11596 - 76 = 11520
So, we can see that 11520 blob bytes are indeed present.
I think the problem might be that
reader.Buffered()
is not returning what you expect, ie. the full number of bytes in the buffered reader but rather just what you get from a single.Read()
on the buffer. There might be a smaller buffer than 11520 bytes in use, and perhaps multiple reads are required?Just a theory. I could be totally wrong... I can drop an actual payload from a packet capture somewhere if it helps.