Pumpkin-MC/Pumpkin · error

hit_count exceeds limit

Error message

hit_count exceeds limit

What it means

Guard in SClientCacheBlobStatus::read raising a generic std::io InvalidData error when the declared hit_count in the client cache blob status packet exceeds 4096, protecting against oversized allocation from hostile packets.

Solutions

  1. Disconnect the client sending the oversized blob status
  2. Keep the 4096 cap to bound memory allocation
  3. Log the violation at debug level

Example fix

// client before
let hits = all_cached_blob_hashes();
// after
let hits: Vec<_> = all_cached_blob_hashes().into_iter().take(4096).collect();
Defensive patterns

Strategy: validation

Validate before calling

fn validate_hit_count(count: u32) -> Result<(), String> {
    if count > 4096 {
        return Err(format!("hit_count {count} exceeds 4096"));
    }
    Ok(())
}

Try / catch

match SClientCacheBlobStatus::read(reader) {
    Err(e) if e.to_string().contains("hit_count") => {
        log::warn!("invalid blob status packet: {e}; dropping client packet");
    }
    other => other?,
}

Prevention

When it happens

Trigger: Triggered by SClientCacheBlobStatus::read when the second VarUInt (hit_count, read after all miss hashes) is greater than 4096.

Common situations: Malicious packets, client bugs, or stream misalignment where the hash reads above consumed wrong offsets making hit_count parse garbage.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


AI-assisted analysis of Pumpkin-MC/Pumpkin@8d4639e25a (2026-09-09). Data as JSON: /api/errors/24c0c99619238345. Report an issue: GitHub.

Appendix: source

Thrown at crates/pumpkin-protocol/src/bedrock/server/client_cache_blob_status.rs:31

}

impl PacketRead for SClientCacheBlobStatus {
    fn read<R: Read>(reader: &mut R) -> Result<Self, Error> {
        let miss_count = VarUInt::read(reader)?.0 as usize;
        if miss_count > 4096 {
            return Err(Error::new(
                std::io::ErrorKind::InvalidData,
                "miss_count exceeds limit",
            ));
        }
        let mut miss_hashes = Vec::with_capacity(miss_count.min(256));
        for _ in 0..miss_count {
            miss_hashes.push(u64::read(reader)?);
        }

        let hit_count = VarUInt::read(reader)?.0 as usize;
        if hit_count > 4096 {
            return Err(Error::new(
                std::io::ErrorKind::InvalidData,
                "hit_count exceeds limit",
            ));
        }
        let mut hit_hashes = Vec::with_capacity(hit_count.min(256));
        for _ in 0..hit_count {
            hit_hashes.push(u64::read(reader)?);
        }

        Ok(Self {
            miss_hashes,
            hit_hashes,
        })
    }
}

View on GitHub (pinned to 8d4639e25a)