From 0981f8566cb8ac818c1bb6ed326af12e4ea06226 Mon Sep 17 00:00:00 2001 From: Andrew Gillis Date: Mon, 3 Apr 2023 07:50:51 -0700 Subject: [PATCH] Update cid.go Co-authored-by: Rod Vagg --- cid.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cid.go b/cid.go index cc7c4b1..6e36764 100644 --- a/cid.go +++ b/cid.go @@ -728,7 +728,8 @@ func CidFromReader(r io.Reader) (int, Cid, error) { vers, err := varint.ReadUvarint(br) if err != nil { if err == io.EOF { - // No data; not an invalid CID. + // First-byte read in ReadUvarint errors with io.EOF, so reader has no data. + // Subsequent reads with an EOF will return io.ErrUnexpectedEOF and be wrapped here. return 0, Undef, err } return len(br.dst), Undef, ErrInvalidCid{err}