Loading src/quic.cpp +330 −164 File changed.Preview size limit exceeded, changes collapsed. Show changes src/socket.h +18 −2 Changes for src/socket.h: 18 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -742,6 +742,12 @@ namespace netplus { void processCryptoFrame(const uint8_t* data, size_t len, size_t& offset); void processStreamFrame(const uint8_t* data, size_t len, size_t& offset); void processAckFrame(const uint8_t* data, size_t len, size_t& offset); // Sends CONNECTION_CLOSE(error_code, reason), drains the connection, // and sets offset = len so the caller's frame loop terminates — // the response to any malformed/truncated frame data parsing hits // (RFC 9000 §12.4: treat it as a connection error, not something to // silently skip past). void abortFrameParsing(size_t len, size_t& offset, uint64_t error_code, const char* reason); // If a stream has terminated in both directions (FIN/RESET on both // send and recv sides), erase it and — for a peer-initiated stream — Loading Loading @@ -795,9 +801,19 @@ namespace netplus { void applyHeaderProtection(std::vector<uint8_t>& packet, const uint8_t* hp_key, bool force_aes128 = false); void removeHeaderProtection(std::vector<uint8_t>& packet, const uint8_t* hp_key, bool force_aes128 = false); // Variable-length integer encoding/decoding (RFC 9000 Section 16) // Variable-length integer encoding/decoding (RFC 9000 Section 16). static size_t encodeVarInt(uint64_t value, uint8_t* out); static uint64_t decodeVarInt(const uint8_t* data, size_t& bytes_read); // decodeVarInt is bounds-checked against `remaining` (the number of // bytes actually available at `data`): if the prefix byte's encoded // length would read past `remaining`, it never touches `data` and // reports failure via bytes_read == 0 — unambiguous, since a real // varint always consumes at least 1 byte. Callers MUST check for // this and abort parsing the current frame/field on failure; as a // second line of defense, every frame/field parsing loop in this // file also carries an explicit progress guard (offset must // advance every iteration or parsing aborts), so a call site that // forgets to check still can't spin forever or read past the end. static uint64_t decodeVarInt(const uint8_t* data, size_t remaining, size_t& bytes_read); static size_t varIntSize(uint64_t value); // Connection ID generation Loading Loading
src/socket.h +18 −2 Changes for src/socket.h: 18 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -742,6 +742,12 @@ namespace netplus { void processCryptoFrame(const uint8_t* data, size_t len, size_t& offset); void processStreamFrame(const uint8_t* data, size_t len, size_t& offset); void processAckFrame(const uint8_t* data, size_t len, size_t& offset); // Sends CONNECTION_CLOSE(error_code, reason), drains the connection, // and sets offset = len so the caller's frame loop terminates — // the response to any malformed/truncated frame data parsing hits // (RFC 9000 §12.4: treat it as a connection error, not something to // silently skip past). void abortFrameParsing(size_t len, size_t& offset, uint64_t error_code, const char* reason); // If a stream has terminated in both directions (FIN/RESET on both // send and recv sides), erase it and — for a peer-initiated stream — Loading Loading @@ -795,9 +801,19 @@ namespace netplus { void applyHeaderProtection(std::vector<uint8_t>& packet, const uint8_t* hp_key, bool force_aes128 = false); void removeHeaderProtection(std::vector<uint8_t>& packet, const uint8_t* hp_key, bool force_aes128 = false); // Variable-length integer encoding/decoding (RFC 9000 Section 16) // Variable-length integer encoding/decoding (RFC 9000 Section 16). static size_t encodeVarInt(uint64_t value, uint8_t* out); static uint64_t decodeVarInt(const uint8_t* data, size_t& bytes_read); // decodeVarInt is bounds-checked against `remaining` (the number of // bytes actually available at `data`): if the prefix byte's encoded // length would read past `remaining`, it never touches `data` and // reports failure via bytes_read == 0 — unambiguous, since a real // varint always consumes at least 1 byte. Callers MUST check for // this and abort parsing the current frame/field on failure; as a // second line of defense, every frame/field parsing loop in this // file also carries an explicit progress guard (offset must // advance every iteration or parsing aborts), so a call site that // forgets to check still can't spin forever or read past the end. static uint64_t decodeVarInt(const uint8_t* data, size_t remaining, size_t& bytes_read); static size_t varIntSize(uint64_t value); // Connection ID generation Loading