What changed, and why it matters
This commit is a routine build fix for the firmware simulator. It adds a helper macro that lets a function return NULL on error, fixes a function name typo in a MetaMask wallet helper, and adjusts safe-string macros so they return 0 like their standard-library counterparts. None of these changes appear to be security fixes.
No security action required; treat as normal build-maintenance commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch contains three unrelated build/simulator fixes: (1) adds CHECK_ERRCODE_RETURN_NULL in err_code.h and uses it in gui_btc.c so GetBtcSignDataDynamic returns NULL instead of void when GetAccountSeed fails; (2) wraps memset_s/strcpy_s/strcat_s/strncpy_s fallback macros in a comma expression returning 0 to match the expected errno_t-like return value of the real safe functions; (3) renames a callback argument in gui_wallet.c from get_unlimited_connect_metamask_ur to get_connect_metamask_ur_unlimited, correcting a build-time symbol error. No vulnerability is addressed.
Changed components
src/error_codes/err_code.hsrc/ram/user_memory.hsrc/ui/gui_chain/gui_btc.csrc/ui/gui_wallet/multi/web3/gui_wallet.cInspect captured patch +7 / −6
diff --git a/src/error_codes/err_code.h b/src/error_codes/err_code.h
index 975fe22..7a1dfe4 100644
--- a/src/error_codes/err_code.h
+++ b/src/error_codes/err_code.h
@@ -101,6 +101,7 @@ const char *GetErrorMessage(Error_Code errCode);
#define CHECK_ERRCODE_BREAK(content, ret) {if (ret != SUCCESS_CODE) {printf("%s err,0x%X,line=%d\r\n", content, ret, __LINE__); break; }}
#define CHECK_ERRCODE_RETURN(ret) {if (ret != SUCCESS_CODE) {printf("%s err,%s,line=%d\r\n", __func__, GetErrorMessage(ret), __LINE__); return; }}
+#define CHECK_ERRCODE_RETURN_NULL(ret) {if (ret != SUCCESS_CODE) {printf("%s err,%s,line=%d\r\n", __func__, GetErrorMessage(ret), __LINE__); return NULL; }}
#define CHECK_ERRCODE_RETURN_INT(ret) {if (ret != SUCCESS_CODE) {printf("%s err,%s,line=%d\r\n", __func__, GetErrorMessage(ret), __LINE__); return ret; }}
#define PRINT_ERRCODE(ret) {if (ret != SUCCESS_CODE) {printf("%s err,%s,line=%d\r\n", __func__, GetErrorMessage(ret), __LINE__); }}
diff --git a/src/ram/user_memory.h b/src/ram/user_memory.h
index 110c044..dca5d9d 100644
--- a/src/ram/user_memory.h
+++ b/src/ram/user_memory.h
@@ -28,16 +28,16 @@ void PrintHeapInfo(void);
#define snprintf_s snprintf
#endif
#ifndef memset_s
-#define memset_s(dest, destsz, ch, count) memset(dest, ch, count)
+#define memset_s(dest, destsz, ch, count) (memset(dest, ch, count), 0)
#endif
#ifndef strcpy_s
-#define strcpy_s(dest, destsz, src) strcpy(dest, src)
+#define strcpy_s(dest, destsz, src) (strcpy(dest, src), 0)
#endif
#ifndef strcat_s
-#define strcat_s(dest, destsz, src) strcat(dest, src)
+#define strcat_s(dest, destsz, src) (strcat(dest, src), 0)
#endif
#ifndef strncpy_s
-#define strncpy_s(dest, destsz, src, size) strncpy(dest, src, size)
+#define strncpy_s(dest, destsz, src, size) (strncpy(dest, src, size), 0)
#endif
#define memcpy_s(dest, destsz, src, count) memcpy(dest, src, count)
#define strnlen_s(sstr, smax) strnlen(sstr, smax)
diff --git a/src/ui/gui_chain/gui_btc.c b/src/ui/gui_chain/gui_btc.c
index 1a4aeb7..1333675 100644
--- a/src/ui/gui_chain/gui_btc.c
+++ b/src/ui/gui_chain/gui_btc.c
@@ -239,7 +239,7 @@ static UREncodeResult *GetBtcSignDataDynamic(bool unLimit)
uint8_t seed[64];
int len = GetCurrentAccountSeedLen();
int ret = GetAccountSeed(GetCurrentAccountIndex(), seed, SecretCacheGetPassword());
- CHECK_ERRCODE_RETURN(ret);
+ CHECK_ERRCODE_RETURN_NULL(ret);
if (urType == CryptoPSBT) {
if (GuiGetCurrentTransactionType() == TRANSACTION_TYPE_BTC_MULTISIG) {
diff --git a/src/ui/gui_wallet/multi/web3/gui_wallet.c b/src/ui/gui_wallet/multi/web3/gui_wallet.c
index f34de31..31ddb57 100644
--- a/src/ui/gui_wallet/multi/web3/gui_wallet.c
+++ b/src/ui/gui_wallet/multi/web3/gui_wallet.c
@@ -195,7 +195,7 @@ UREncodeResult *GetMetamaskDataForAccountType(ETHAccountType accountType)
UREncodeResult *GetUnlimitedMetamaskDataForAccountType(ETHAccountType accountType)
{
- return BasicGetMetamaskDataForAccountType(accountType, get_unlimited_connect_metamask_ur);
+ return BasicGetMetamaskDataForAccountType(accountType, get_connect_metamask_ur_unlimited);
}
UREncodeResult *GuiGetMetamaskData(void)
Why this scored 15/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.