Skip to content

map_stats skips writing iggy_server_semver when None, risking binary stream misalignment #2979

@atharvalade

Description

@atharvalade

core/server/src/binary/mapper.rs:60-62 conditionally writes iggy_server_semver only when Some:

if let Some(semver) = stats.iggy_server_semver {
    bytes.put_u32_le(semver);
}

When None, zero bytes are written. But all SDK deserializers (Rust, Java, and the new binary_protocol crate) unconditionally read 4 bytes here, using 0 as the None sentinel. If the server ever sends None, every field after semver gets shifted, corrupting the entire stats response.

The same issue exists in core/binary_protocol/src/responses/system/get_stats.rs:151-153 (semver) and lines 167-171 (where threads_count, free_disk_space, total_disk_space are also conditionally skipped when semver is absent).

This is not critical because it is currently unreachable because the server always derives semver from CARGO_PKG_VERSION via SEMANTIC_VERSION.get_numeric_version().ok(), which succeeds for any valid version. But it's a latent correctness issue.

Fix: bytes.put_u32_le(stats.iggy_server_semver.unwrap_or(0)); and always write the tail fields unconditionally.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions