Browse Source

fix VolumeEcShardsToVolume to validate dataShards range

Go validates that dataShards is > 0 and <= MaxShardCount before
proceeding with EC-to-volume reconstruction. Without this check,
a zero or excessively large data_shards value could cause confusing
downstream failures.
rust-volume-server
Chris Lu 7 days ago
parent
commit
4dd68645cb
  1. 9
      seaweed-volume/src/server/grpc_server.rs

9
seaweed-volume/src/server/grpc_server.rs

@ -2587,6 +2587,15 @@ impl VolumeServer for VolumeGrpcService {
// Use EC context data shard count from the volume
let data_shards = ec_vol.data_shards as usize;
// Validate data shard count range (matches Go's VolumeEcShardsToVolume)
let max_shard_count = crate::storage::erasure_coding::ec_shard::MAX_SHARD_COUNT;
if data_shards == 0 || data_shards > max_shard_count {
return Err(Status::invalid_argument(format!(
"invalid data shard count {} for volume {} (must be 1..{})",
data_shards, req.volume_id, max_shard_count
)));
}
// Check that all data shards are present
for shard_id in 0..data_shards {
if ec_vol

Loading…
Cancel
Save