Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merging develop to master #3

Merged
merged 23 commits into from
Feb 14, 2025
Merged

Merging develop to master #3

merged 23 commits into from
Feb 14, 2025

Conversation

iartemov-ledger
Copy link

No description provided.

0xPxt and others added 21 commits October 29, 2024 11:54
* Stax & Flex porting (Zondax#13)

* flex_porting

* bump version

* update readme

* set production build flag accordingly

* bump minor version instead of patch

* update ledger_app.toml

* resize flex icon

* Add support for coston testnet
* update zxlib

* bump version
* update deps

* update coston network_id & add new chain ids

* update snapshots
Stax/Flex Support and Support for Coston Testnet (chain_id = 16) for ETH transactions
* remove js package

* add js submodule

* update tests

* update snapshots
* update submodules

* add blindsign ui

* update tests

* update snapshots

* update test and snapshots for sign hash

* fix error return
* update deps and submodules

* coin asset depending on chain id

* update zxlib

* add blindsign required flag

* update tests

* update snapshots
* move files to evm folder

* update remaining code structure

* update fuzzer and tests

* small argument fix
* add sign_personal

* update js package

* update snapshots
* update zxlib

* update deps

* update snapshots
* add switch to coin asset

* update snapshots

* add test

* update snapshots
* add  flare CLA extra verification

* remove not needed DER signature from response

* update zxlib

* bump version

* update fuzzer

* update docs

* update docs
* add  flare CLA extra verification

* remove not needed DER signature from response

* update zxlib

* bump version

* update fuzzer

* update docs

* update docs
Comment on lines +143 to +218
switch (payloadType) {
case P1_ETH_FIRST:
tx_initialize();
tx_reset();
extract_eth_path(rx, OFFSET_DATA);
// there is not warranties that the first chunk
// contains the serialized path only;
// so we need to offset the data to point to the first transaction
// byte
uint32_t path_len = sizeof(uint32_t) * hdPathEth_len;

// plus the first offset data containing the path len
data += path_len + 1;
if (len < path_len) {
THROW(APDU_CODE_WRONG_LENGTH);
}

// now process the chunk
len -= path_len + 1;
if (get_tx_rlp_len(data, len, &read, &to_read) != rlp_ok) {
THROW(APDU_CODE_DATA_INVALID);
}

// get remaining data len
max_len = saturating_add(read, to_read);
max_len = MIN(max_len, len);

added = tx_append(data, max_len);
if (added != max_len) {
THROW(APDU_CODE_OUTPUT_BUFFER_TOO_SMALL);
}

tx_initialized = true;

// if the number of bytes read and the number of bytes to read
// is the same as what we read...
if ((saturating_add(read, to_read) - len) == 0) {
return true;
}
return false;
case P1_ETH_MORE:
if (!tx_initialized) {
THROW(APDU_CODE_TX_NOT_INITIALIZED);
}

uint64_t buff_len = tx_get_buffer_length();
uint8_t *buff_data = tx_get_buffer();

if (get_tx_rlp_len(buff_data, buff_len, &read, &to_read) != rlp_ok) {
THROW(APDU_CODE_DATA_INVALID);
}

uint64_t rlp_read = buff_len - read;

// either the entire buffer of the remaining bytes we expect
uint64_t missing = to_read - rlp_read;
max_len = len;

if (missing < len) {
max_len = missing;
}
added = tx_append(data, max_len);

if (added != max_len) {
tx_initialized = false;
THROW(APDU_CODE_OUTPUT_BUFFER_TOO_SMALL);
}

// check if this chunk was the last one
if (missing - len == 0) {
tx_initialized = false;
return true;
}

return false;
}

Check notice

Code scanning / CodeQL

Long switch case Note

Switch has at least one case that is too long:
0 (38 lines)
.
Switch has at least one case that is too long:
128 (34 lines)
.
Copy link

socket-security bot commented Feb 14, 2025

@iartemov-ledger iartemov-ledger merged commit 0d44f75 into master Feb 14, 2025
57 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants