mirror of
https://github.com/0xfnzero/solana-streamer.git
synced 2026-08-23 13:58:06 +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:
@@ -30,7 +30,7 @@ pub struct AmmConfig {
|
||||
pub const AMM_CONFIG_SIZE: usize = 228;
|
||||
|
||||
pub fn amm_config_decode(data: &[u8]) -> Option<AmmConfig> {
|
||||
borsh::from_slice::<AmmConfig>(&data).ok()
|
||||
borsh::from_slice::<AmmConfig>(&data[..AMM_CONFIG_SIZE]).ok()
|
||||
}
|
||||
|
||||
pub fn amm_config_parser(
|
||||
@@ -85,7 +85,7 @@ pub struct PoolState {
|
||||
pub const POOL_STATE_SIZE: usize = 629;
|
||||
|
||||
pub fn pool_state_decode(data: &[u8]) -> Option<PoolState> {
|
||||
borsh::from_slice::<PoolState>(&data).ok()
|
||||
borsh::from_slice::<PoolState>(&data[..POOL_STATE_SIZE]).ok()
|
||||
}
|
||||
|
||||
pub fn pool_state_parser(
|
||||
|
||||
Reference in New Issue
Block a user