Commit bb6607b2 authored by jan.koester's avatar jan.koester
Browse files

test

parent a882f3d3
Loading
Loading
Loading
Loading
+17 −1
Changes for src/quic.cpp: 17 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -967,6 +967,22 @@ bool constantTimeEqual(const uint8_t* a, const uint8_t* b, size_t len) {
    return diff == 0;
}

// The real wire length of a peer address, by family — NOT
// sizeof(sockaddr_storage). Linux's sendto()/sendmsg() tolerate an
// oversized msg_namelen/addrlen (it just reads sizeof(sockaddr_in{,6})
// worth of bytes based on ss_family and ignores the rest), so passing
// sizeof(sockaddr_storage) there silently "worked" by accident. FreeBSD's
// kqueue-backed stack validates the length strictly and rejects the
// mismatch with EINVAL — this was breaking every send to a peer (Retry,
// handshake flight, and all post-handshake application data via
// flushBatch()'s _AddrLen) on kqueue platforms, while epoll/Linux masked
// it completely.
socklen_t sockaddrLen(const sockaddr_storage& addr) {
    if (addr.ss_family == AF_INET) return sizeof(struct sockaddr_in);
    if (addr.ss_family == AF_INET6) return sizeof(struct sockaddr_in6);
    return sizeof(sockaddr_storage);
}

} // namespace

std::array<uint8_t, 16> quic::computeRetryIntegrityTag(
@@ -2254,7 +2270,7 @@ void quic::accept(std::unique_ptr<socket>& csock, bool nonblock) {
    total_processed++;
    auto& dgram = datagrams[msg_i];
    sockaddr_storage& peer_addr = addrs[msg_i];
    socklen_t peer_len = sizeof(sockaddr_storage);
    socklen_t peer_len = sockaddrLen(peer_addr);

    if (dgram.size() < 1) continue;