Skip to content

Commit 0680588

Browse files
committed
Fix buffer overwrite
1 parent fc5a004 commit 0680588

File tree

1 file changed

+7
-3
lines changed
  • ledger_device_sdk/src/libcall

1 file changed

+7
-3
lines changed

ledger_device_sdk/src/libcall/swap.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,9 @@ pub fn get_check_address_params<const COIN_CONFIG_BUF_SIZE: usize>(
112112
unsafe {
113113
params.coin_configuration.copy_to_nonoverlapping(
114114
check_address_params.coin_config.as_mut_ptr(),
115-
check_address_params.coin_config_len,
115+
check_address_params
116+
.coin_config_len
117+
.min(COIN_CONFIG_BUF_SIZE),
116118
);
117119
}
118120

@@ -172,7 +174,9 @@ pub fn get_printable_amount_params<const COIN_CONFIG_BUF_SIZE: usize>(
172174
unsafe {
173175
params.coin_configuration.copy_to_nonoverlapping(
174176
printable_amount_params.coin_config.as_mut_ptr(),
175-
printable_amount_params.coin_config_len,
177+
printable_amount_params
178+
.coin_config_len
179+
.min(COIN_CONFIG_BUF_SIZE),
176180
);
177181
}
178182

@@ -230,7 +234,7 @@ pub fn sign_tx_params<const COIN_CONFIG_BUF_SIZE: usize>(
230234
unsafe {
231235
params.coin_configuration.copy_to_nonoverlapping(
232236
create_tx_params.coin_config.as_mut_ptr(),
233-
create_tx_params.coin_config_len,
237+
create_tx_params.coin_config_len.min(COIN_CONFIG_BUF_SIZE),
234238
);
235239
}
236240

0 commit comments

Comments
 (0)