Skip to content

Commit

Permalink
Merge pull request #29 from blooo-io/fix/04-04-24-security-audit
Browse files Browse the repository at this point in the history
Fix/04 04 24 security audit
  • Loading branch information
Z4karia authored Apr 5, 2024
2 parents d07c467 + a92d12e commit 2fa3ad1
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 25 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ APPNAME = "StakeKit"
# Application version
APPVERSION_M = 1
APPVERSION_N = 2
APPVERSION_P = 0
APPVERSION_P = 1

include ethereum-plugin-sdk/standard_plugin.mk
52 changes: 28 additions & 24 deletions src/handle_finalize.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,20 @@
static bool set_ticker_deposit_for_mapped_token(plugin_parameters_t *context,
ethPluginFinalize_t *msg) {
for (size_t i = 0; i < NUM_SUPPORTED_SMART_CONTRACT; i++) {
if (!memcmp(msg->pluginSharedRO->txContent->destination,
STAKEKIT_SUPPORTED_YEARN_VAULT[i].smart_contract,
ADDRESS_LENGTH)) {
char ticker[TICKER_LEN];
strlcpy(ticker,
(char *) STAKEKIT_SUPPORTED_YEARN_VAULT[i].token_symbol_deposit,
sizeof(ticker));
strlcat(ticker, " ", sizeof(ticker));
strlcpy(context->ticker_sent, (char *) ticker, sizeof(context->ticker_sent));
context->decimals_sent = STAKEKIT_SUPPORTED_YEARN_VAULT[i].decimals_sent;
context->tokens_found |= TOKEN_SENT_FOUND;
return true;
if (msg != NULL && msg->pluginSharedRO != NULL && msg->pluginSharedRO->txContent != NULL) {
if (!memcmp(msg->pluginSharedRO->txContent->destination,
STAKEKIT_SUPPORTED_YEARN_VAULT[i].smart_contract,
ADDRESS_LENGTH)) {
char ticker[TICKER_LEN];
strlcpy(ticker,
(char *) STAKEKIT_SUPPORTED_YEARN_VAULT[i].token_symbol_deposit,
sizeof(ticker));
strlcat(ticker, " ", sizeof(ticker));
strlcpy(context->ticker_sent, (char *) ticker, sizeof(context->ticker_sent));
context->decimals_sent = STAKEKIT_SUPPORTED_YEARN_VAULT[i].decimals_sent;
context->tokens_found |= TOKEN_SENT_FOUND;
return true;
}
}
}
return false;
Expand All @@ -30,18 +32,20 @@ static bool set_ticker_deposit_for_mapped_token(plugin_parameters_t *context,
static bool set_ticker_withdraw_for_mapped_token(plugin_parameters_t *context,
ethPluginFinalize_t *msg) {
for (size_t i = 0; i < NUM_SUPPORTED_SMART_CONTRACT; i++) {
if (!memcmp(msg->pluginSharedRO->txContent->destination,
STAKEKIT_SUPPORTED_YEARN_VAULT[i].smart_contract,
ADDRESS_LENGTH)) {
char ticker[TICKER_LEN];
strlcpy(ticker,
(char *) STAKEKIT_SUPPORTED_YEARN_VAULT[i].token_symbol_withdraw,
sizeof(ticker));
strlcat(ticker, " ", sizeof(ticker));
strlcpy(context->ticker_sent, (char *) ticker, sizeof(context->ticker_sent));
context->decimals_sent = STAKEKIT_SUPPORTED_YEARN_VAULT[i].decimals_sent;
context->tokens_found |= TOKEN_SENT_FOUND;
return true;
if (msg != NULL && msg->pluginSharedRO != NULL && msg->pluginSharedRO->txContent != NULL) {
if (!memcmp(msg->pluginSharedRO->txContent->destination,
STAKEKIT_SUPPORTED_YEARN_VAULT[i].smart_contract,
ADDRESS_LENGTH)) {
char ticker[TICKER_LEN];
strlcpy(ticker,
(char *) STAKEKIT_SUPPORTED_YEARN_VAULT[i].token_symbol_withdraw,
sizeof(ticker));
strlcat(ticker, " ", sizeof(ticker));
strlcpy(context->ticker_sent, (char *) ticker, sizeof(context->ticker_sent));
context->decimals_sent = STAKEKIT_SUPPORTED_YEARN_VAULT[i].decimals_sent;
context->tokens_found |= TOKEN_SENT_FOUND;
return true;
}
}
}
return false;
Expand Down
3 changes: 3 additions & 0 deletions src/handle_query_contract_ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ static void set_receive_2_ui(ethQueryContractUI_t *msg, plugin_parameters_t *con

// Utility function to print an address to the UI.
static void print_address(ethQueryContractUI_t *msg, uint8_t *address) {
if (msg == NULL || msg->msgLength <= MIN_MSG_LENGTH) {
return;
}
// Prefix the address with `0x`.
msg->msg[0] = '0';
msg->msg[1] = 'x';
Expand Down
2 changes: 2 additions & 0 deletions src/stakekit_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ extern const tokenSymbolAndDecimals_t STAKEKIT_SUPPORTED_YEARN_VAULT[NUM_SUPPORT

#define CHAIN_ID_LENGTH 1

#define MIN_MSG_LENGTH 42

extern const uint8_t NULL_ETH_ADDRESS[ADDRESS_LENGTH];

// Returns 1 if corresponding address is the address for the chain token (ETH, BNB, MATIC,...)
Expand Down

0 comments on commit 2fa3ad1

Please sign in to comment.