Commit 1ee72b94 authored by jan.koester's avatar jan.koester
Browse files

test

parent f6edbb9d
Loading
Loading
Loading
Loading
+12 −1
Changes for src/quic.cpp: 12 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -1285,7 +1285,8 @@ bool quic::unprotectPacket(const uint8_t* data, size_t len,
                            std::vector<uint8_t>& header,
                            std::vector<uint8_t>& payload,
                            uint64_t& packet_number,
                            EncryptionLevel level, LevelKeyMaterial& mat) {
                            EncryptionLevel level, LevelKeyMaterial& mat,
                            size_t pn_offset_hint) {
    if (len < 20) {
        return false;  // Minimum packet size
    }
@@ -1298,6 +1299,15 @@ bool quic::unprotectPacket(const uint8_t* data, size_t len,
    size_t pn_offset;

    if (is_long) {
        if (pn_offset_hint != SIZE_MAX && pn_offset_hint <= len) {
            // Caller (processInitialPacket/processHandshakePacket) already
            // parsed this same long header once — reuse its result instead
            // of walking DCID/SCID/token/length again (F08). Everything
            // below (sample_offset/header_len/ciphertext_len bounds checks)
            // still validates independently of where pn_offset came from,
            // so a wrong hint fails the AEAD tag rather than reading OOB.
            pn_offset = pn_offset_hint;
        } else {
            size_t offset = 5;
            if (offset >= len) return false;
            uint8_t dcid_len = data[offset++];
@@ -1323,6 +1333,7 @@ bool quic::unprotectPacket(const uint8_t* data, size_t len,
            if (len_bytes == 0) return false;
            offset += len_bytes;
            pn_offset = offset;
        }
    } else {
        pn_offset = 1 + _local_cid.size();
    }