cloudflare/quiche · critical

The provided buffer is too large

Error message

The provided buffer is too large

What it means

The C FFI entry point quiche_conn_recv panics if the caller passes a receive buffer whose length exceeds ssize_t::MAX. Such a length is impossible for a real datagram and would make the function's ssize_t return convention ambiguous (a successful byte count could alias an error code). The check is a defensive guard on the raw FFI boundary.

Solutions

  1. Fix the caller to pass the true buffer size (must be <= SSIZE_MAX and realistically <= 65527 for QUIC datagrams).
  2. Initialize buf_len properly and check the computation that produced it for overflow or sign errors.
  3. Add a caller-side assert(buf_len <= SSIZE_MAX) before invoking quiche_conn_recv.

Example fix

// before
ssize_t n = quiche_conn_recv(conn, buf, (size_t)-1, &info);
// after
size_t buf_len = 65527;
assert(buf_len <= SSIZE_MAX);
ssize_t n = quiche_conn_recv(conn, buf, buf_len, &info);
Defensive patterns

Strategy: validation

Validate before calling

if (buf_len > (size_t)SSIZE_MAX) { /* reject before calling */ abort(); }
ssize_t n = quiche_conn_recv(conn, buf, buf_len, &info);

Prevention

When it happens

Trigger: Calling quiche_conn_recv from C/C++ (or any FFI caller) with buf_len larger than SSIZE_MAX — typically from an uninitialized, corrupted, or wrongly sized length variable.

Common situations: Uninitialized size_t passed as buf_len; integer overflow when computing the buffer length; passing a negative int that was cast to size_t (wrapping to a huge value).

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of cloudflare/quiche@9f96daa2c2 (2026-09-08). Data as JSON: /api/errors/057042471850c8e8. Report an issue: GitHub.

Appendix: source

Thrown at quiche/src/ffi.rs:855

    to: &'a sockaddr,
    to_len: socklen_t,
}

impl From<&RecvInfo<'_>> for crate::RecvInfo {
    fn from(info: &RecvInfo) -> crate::RecvInfo {
        crate::RecvInfo {
            from: std_addr_from_c(info.from, info.from_len),
            to: std_addr_from_c(info.to, info.to_len),
        }
    }
}

#[no_mangle]
pub extern "C" fn quiche_conn_recv(
    conn: &mut Connection, buf: *mut u8, buf_len: size_t, info: &RecvInfo,
) -> ssize_t {
    if buf_len > <ssize_t>::MAX as usize {
        panic!("The provided buffer is too large");
    }

    let buf = unsafe { slice::from_raw_parts_mut(buf, buf_len) };

    match conn.recv(buf, info.into()) {
        Ok(v) => v as ssize_t,

        Err(e) => e.to_c(),
    }
}

#[repr(C)]
pub struct SendInfo {
    from: sockaddr_storage,
    from_len: socklen_t,
    to: sockaddr_storage,
    to_len: socklen_t,

View on GitHub (pinned to 9f96daa2c2)