Cleanup os_mem* functions
This commit is contained in:
committed by
TamtamHero
parent
374580431d
commit
d43f7f6698
@@ -4,7 +4,7 @@
|
||||
#include "ethUtils.h"
|
||||
#include "string.h"
|
||||
|
||||
#define ZERO(x) os_memset(x, 0, sizeof(x))
|
||||
#define ZERO(x) memset(x, 0, sizeof(x))
|
||||
|
||||
void handle_check_address(check_address_parameters_t* params, chain_config_t* chain_config) {
|
||||
PRINTF("Params on the address %d\n",(unsigned int)params);
|
||||
@@ -60,10 +60,10 @@ void handle_check_address(check_address_parameters_t* params, chain_config_t* ch
|
||||
}
|
||||
|
||||
if ((strlen(locals_union1.address) != strlen(params->address_to_check + offset_0x)) ||
|
||||
os_memcmp(locals_union1.address, params->address_to_check + offset_0x, strlen(locals_union1.address)) != 0) {
|
||||
memcmp(locals_union1.address, params->address_to_check + offset_0x, strlen(locals_union1.address)) != 0) {
|
||||
PRINTF("Addresses doesn't match\n");
|
||||
return;
|
||||
}
|
||||
PRINTF("Addresses match\n");
|
||||
params->result = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
void handle_get_printable_amount( get_printable_amount_parameters_t* params, chain_config_t *config) {
|
||||
uint8_t decimals;
|
||||
char ticker[MAX_TICKER_LEN];
|
||||
os_memset(params->printable_amount, 0, sizeof(params->printable_amount));
|
||||
memset(params->printable_amount, 0, sizeof(params->printable_amount));
|
||||
if (params->amount_length > 32) {
|
||||
PRINTF("Amount is too big, 32 bytes max but buffer has %u bytes", params->amount_length);
|
||||
os_lib_end();
|
||||
@@ -30,4 +30,4 @@ void handle_get_printable_amount( get_printable_amount_parameters_t* params, cha
|
||||
}
|
||||
|
||||
amountToString(params->amount, params->amount_length, decimals, ticker, params->printable_amount, sizeof(params->printable_amount));
|
||||
}
|
||||
}
|
||||
|
||||
22
src/main.c
22
src/main.c
@@ -69,7 +69,7 @@ chain_config_t *chainConfig;
|
||||
void reset_app_context() {
|
||||
//PRINTF("!!RESET_APP_CONTEXT\n");
|
||||
appState = APP_STATE_IDLE;
|
||||
os_memset(tmpCtx.transactionContext.tokenSet, 0, MAX_TOKEN);
|
||||
memset(tmpCtx.transactionContext.tokenSet, 0, MAX_TOKEN);
|
||||
called_from_swap = false;
|
||||
#ifdef HAVE_STARKWARE
|
||||
quantumSet = false;
|
||||
@@ -77,8 +77,8 @@ void reset_app_context() {
|
||||
#ifdef HAVE_ETH2
|
||||
eth2WithdrawalIndex = 0;
|
||||
#endif
|
||||
os_memset((uint8_t*)&txContext, 0, sizeof(txContext));
|
||||
os_memset((uint8_t*)&tmpContent, 0, sizeof(tmpContent));
|
||||
memset((uint8_t*)&txContext, 0, sizeof(txContext));
|
||||
memset((uint8_t*)&tmpContent, 0, sizeof(tmpContent));
|
||||
}
|
||||
|
||||
void ui_idle(void) {
|
||||
@@ -118,7 +118,7 @@ void io_seproxyhal_send_status(uint32_t sw) {
|
||||
}
|
||||
|
||||
void format_signature_out(const uint8_t* signature) {
|
||||
os_memset(G_io_apdu_buffer + 1, 0x00, 64);
|
||||
memset(G_io_apdu_buffer + 1, 0x00, 64);
|
||||
uint8_t offset = 1;
|
||||
uint8_t xoffset = 4; //point to r value
|
||||
//copy r
|
||||
@@ -355,14 +355,14 @@ tokenDefinition_t* getKnownToken(uint8_t *contractAddress) {
|
||||
currentToken = (tokenDefinition_t *)PIC(&TOKENS_THUNDERCORE[i]);
|
||||
break
|
||||
}
|
||||
if (os_memcmp(currentToken->address, tmpContent.txContent.destination, 20) == 0) {
|
||||
if (memcmp(currentToken->address, tmpContent.txContent.destination, 20) == 0) {
|
||||
return currentToken;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
for(size_t i=0; i<MAX_TOKEN; i++){
|
||||
currentToken = &tmpCtx.transactionContext.tokens[i];
|
||||
if (tmpCtx.transactionContext.tokenSet[i] && (os_memcmp(currentToken->address, contractAddress, 20) == 0)) {
|
||||
if (tmpCtx.transactionContext.tokenSet[i] && (memcmp(currentToken->address, contractAddress, 20) == 0)) {
|
||||
PRINTF("Token found at index %d\n", i);
|
||||
return currentToken;
|
||||
}
|
||||
@@ -409,7 +409,7 @@ void handleApdu(unsigned int *flags, unsigned int *tx) {
|
||||
|
||||
switch (G_io_apdu_buffer[OFFSET_INS]) {
|
||||
case INS_GET_PUBLIC_KEY:
|
||||
os_memset(tmpCtx.transactionContext.tokenSet, 0, MAX_TOKEN);
|
||||
memset(tmpCtx.transactionContext.tokenSet, 0, MAX_TOKEN);
|
||||
handleGetPublicKey(G_io_apdu_buffer[OFFSET_P1], G_io_apdu_buffer[OFFSET_P2], G_io_apdu_buffer + OFFSET_CDATA, G_io_apdu_buffer[OFFSET_LC], flags, tx);
|
||||
break;
|
||||
|
||||
@@ -426,19 +426,19 @@ void handleApdu(unsigned int *flags, unsigned int *tx) {
|
||||
break;
|
||||
|
||||
case INS_SIGN_PERSONAL_MESSAGE:
|
||||
os_memset(tmpCtx.transactionContext.tokenSet, 0, MAX_TOKEN);
|
||||
memset(tmpCtx.transactionContext.tokenSet, 0, MAX_TOKEN);
|
||||
handleSignPersonalMessage(G_io_apdu_buffer[OFFSET_P1], G_io_apdu_buffer[OFFSET_P2], G_io_apdu_buffer + OFFSET_CDATA, G_io_apdu_buffer[OFFSET_LC], flags, tx);
|
||||
break;
|
||||
|
||||
case INS_SIGN_EIP_712_MESSAGE:
|
||||
os_memset(tmpCtx.transactionContext.tokenSet, 0, MAX_TOKEN);
|
||||
memset(tmpCtx.transactionContext.tokenSet, 0, MAX_TOKEN);
|
||||
handleSignEIP712Message(G_io_apdu_buffer[OFFSET_P1], G_io_apdu_buffer[OFFSET_P2], G_io_apdu_buffer + OFFSET_CDATA, G_io_apdu_buffer[OFFSET_LC], flags, tx);
|
||||
break;
|
||||
|
||||
#ifdef HAVE_ETH2
|
||||
|
||||
case INS_GET_ETH2_PUBLIC_KEY:
|
||||
os_memset(tmpCtx.transactionContext.tokenSet, 0, MAX_TOKEN);
|
||||
memset(tmpCtx.transactionContext.tokenSet, 0, MAX_TOKEN);
|
||||
handleGetEth2PublicKey(G_io_apdu_buffer[OFFSET_P1], G_io_apdu_buffer[OFFSET_P2], G_io_apdu_buffer + OFFSET_CDATA, G_io_apdu_buffer[OFFSET_LC], flags, tx);
|
||||
break;
|
||||
|
||||
@@ -678,7 +678,7 @@ void coin_main_with_config(chain_config_t *config) {
|
||||
}
|
||||
|
||||
void init_coin_config(chain_config_t *coin_config) {
|
||||
os_memset(coin_config, 0, sizeof(chain_config_t));
|
||||
memset(coin_config, 0, sizeof(chain_config_t));
|
||||
strcpy(coin_config->coinName, CHAINID_COINNAME " ");
|
||||
coin_config->chainId = CHAIN_ID;
|
||||
coin_config->kind = CHAIN_KIND;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "poorstream.h"
|
||||
|
||||
void poorstream_init(poorstream_t *stream, uint8_t *buffer) {
|
||||
os_memset((void*)stream, 0, sizeof(poorstream_t));
|
||||
memset((void*)stream, 0, sizeof(poorstream_t));
|
||||
stream->pointer = buffer;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,8 +37,8 @@ void array_hexstr(char *strbuf, const void *bin, unsigned int len) {
|
||||
|
||||
void convertUint256BE(uint8_t *data, uint32_t length, uint256_t *target) {
|
||||
uint8_t tmp[32];
|
||||
os_memset(tmp, 0, 32);
|
||||
os_memmove(tmp + 32 - length, data, length);
|
||||
memset(tmp, 0, 32);
|
||||
memmove(tmp + 32 - length, data, length);
|
||||
readu256BE(tmp, target);
|
||||
}
|
||||
|
||||
@@ -113,4 +113,4 @@ bool parse_swap_config(uint8_t* config, uint8_t config_len, char* ticker, uint8_
|
||||
}
|
||||
*decimals = config[offset];
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user