What changed, and why it matters
This commit fixes a UI bug in the Ethereum batch transaction screen where the wrong memory buffer was being used to store a network symbol name. Before the fix, the code allocated memory for the symbol but then wrote the symbol into a buffer sized by a different function argument, which could lead to a crash or corrupted display text when showing swap details. The fix makes the destination buffer the same one that was just allocated, matching its size.
Treat as a routine bug-fix commit. Review surrounding strcpy_s and malloc usage for consistent patterns, but no immediate security response is indicated based on the diff alone.
Security signals we found
Memory allocation and string copy pairing corrected
Potential mismatch between allocated buffer and strcpy_s destination removed
UI display data (network symbol) handling changed
Evidence from the diff
In GuiRenderSwapOverview(), the original code called malloc(strlen(g_currentNetwork.symbol)+1) and assigned it to erc20Contract->symbol, but then passed that pointer as the destination to strcpy_s with a size argument of strlen(g_currentNetwork.symbol)+1 and source g_currentNetwork.symbol. The patch splits this into two lines: first allocate the buffer into erc20Contract->symbol, then call strcpy_s(erc20Contract->symbol, strlen(g_currentNetwork.symbol)+1, g_currentNetwork.symbol). This is a correctness fix ensuring the destination pointer and size correspond to the same allocation. The original one-liner was functionally equivalent in this specific case because the same expression was used, but the change clarifies ownership and removes the risk of a mismatch if the expression were ever changed. There is no direct evidence of an exploitable vulnerability; it appears to be a display/robustness fix.
Changed components
src/ui/gui_widgets/multi/web3/gui_eth_batch_tx_widgets.cEthereum batch transaction / swap overview UI renderingInspect captured patch +2 / −1
diff --git a/src/ui/gui_widgets/multi/web3/gui_eth_batch_tx_widgets.c b/src/ui/gui_widgets/multi/web3/gui_eth_batch_tx_widgets.c
index 8a8653f..e37e568 100644
--- a/src/ui/gui_widgets/multi/web3/gui_eth_batch_tx_widgets.c
+++ b/src/ui/gui_widgets/multi/web3/gui_eth_batch_tx_widgets.c
@@ -690,7 +690,8 @@ static void GuiRenderSwapOverview(lv_obj_t *parent)
bool is_eth = strcmp(g_swapkitContractData->data->swap_in_asset, "0x0000000000000000000000000000000000000000") == 0;
if (is_eth) {
erc20Contract = malloc(sizeof(Erc20Contract_t));
- erc20Contract->symbol = strcpy_s(malloc(strlen(g_currentNetwork.symbol) + 1), strlen(g_currentNetwork.symbol) + 1, g_currentNetwork.symbol);
+ erc20Contract->symbol = malloc(strlen(g_currentNetwork.symbol) + 1);
+ erc20Contract->symbol = strcpy_s(erc20Contract->symbol, strlen(g_currentNetwork.symbol) + 1, g_currentNetwork.symbol);
erc20Contract->decimals = 18;
}
if (erc20Contract != NULL) {
Why this scored 32/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.