mirror of
https://github.com/0xfnzero/solana-streamer.git
synced 2026-08-22 13:28:08 +00:00
fix: use fixed-size slices for protocol data parsing
- Improve borsh deserialization safety across all protocol decoders - Add MarketState support for raydium_amm_v4 - Prevent buffer overflow in data decoding operations
This commit is contained in:
@@ -120,7 +120,7 @@ pub fn pool_state_decode(data: &[u8]) -> Option<PoolState> {
|
||||
if data.len() < POOL_STATE_SIZE {
|
||||
return None;
|
||||
}
|
||||
borsh::from_slice::<PoolState>(&data).ok()
|
||||
borsh::from_slice::<PoolState>(&data[..POOL_STATE_SIZE]).ok()
|
||||
}
|
||||
|
||||
pub fn pool_state_parser(
|
||||
@@ -168,7 +168,7 @@ pub fn global_config_decode(data: &[u8]) -> Option<GlobalConfig> {
|
||||
if data.len() < GLOBAL_CONFIG_SIZE {
|
||||
return None;
|
||||
}
|
||||
borsh::from_slice::<GlobalConfig>(&data).ok()
|
||||
borsh::from_slice::<GlobalConfig>(&data[..GLOBAL_CONFIG_SIZE]).ok()
|
||||
}
|
||||
|
||||
pub fn global_config_parser(
|
||||
@@ -211,7 +211,7 @@ pub fn platform_config_decode(data: &[u8]) -> Option<PlatformConfig> {
|
||||
if data.len() < PLATFORM_CONFIG_SIZE {
|
||||
return None;
|
||||
}
|
||||
borsh::from_slice::<PlatformConfig>(&data).ok()
|
||||
borsh::from_slice::<PlatformConfig>(&data[..PLATFORM_CONFIG_SIZE]).ok()
|
||||
}
|
||||
|
||||
pub fn platform_config_parser(
|
||||
|
||||
Reference in New Issue
Block a user