diff --git a/frames/ack_frame.go b/frames/ack_frame.go index b68b4482..07cbfe13 100644 --- a/frames/ack_frame.go +++ b/frames/ack_frame.go @@ -83,7 +83,7 @@ func ParseAckFrame(r *bytes.Reader, version protocol.VersionNumber) (*AckFrame, if err != nil { return nil, err } - if ackBlockLength < 1 { + if frame.LargestAcked > 0 && ackBlockLength < 1 { return nil, ErrInvalidFirstAckRange } @@ -141,7 +141,11 @@ func ParseAckFrame(r *bytes.Reader, version protocol.VersionNumber) (*AckFrame, frame.LowestAcked = frame.AckRanges[len(frame.AckRanges)-1].FirstPacketNumber } else { - frame.LowestAcked = protocol.PacketNumber(largestAcked + 1 - ackBlockLength) + if frame.LargestAcked == 0 { + frame.LowestAcked = 0 + } else { + frame.LowestAcked = protocol.PacketNumber(largestAcked + 1 - ackBlockLength) + } } if !frame.validateAckRanges() { diff --git a/frames/ack_frame_test.go b/frames/ack_frame_test.go index 1c86ff81..1928179e 100644 --- a/frames/ack_frame_test.go +++ b/frames/ack_frame_test.go @@ -29,6 +29,16 @@ var _ = Describe("AckFrame", func() { Expect(frame.LargestAcked).To(Equal(protocol.PacketNumber(3))) }) + It("parses a frame where the largest acked is 0", func() { + b := bytes.NewReader([]byte{0x40, 0x0, 0xff, 0xff, 0x0, 0x0}) + frame, err := ParseAckFrame(b, 0) + Expect(err).ToNot(HaveOccurred()) + Expect(frame.LargestAcked).To(Equal(protocol.PacketNumber(0))) + Expect(frame.LowestAcked).To(Equal(protocol.PacketNumber(0))) + Expect(frame.HasMissingRanges()).To(BeFalse()) + Expect(b.Len()).To(BeZero()) + }) + It("parses a frame with a 48 bit packet number", func() { b := bytes.NewReader([]byte{0x4c, 0x37, 0x13, 0xad, 0xfb, 0xca, 0xde, 0x0, 0x0, 0x5, 0x1, 0, 0, 0, 0, 0}) frame, err := ParseAckFrame(b, 0)