Skip to content

Commit

Permalink
Merge pull request #11 from Zondax/fixes
Browse files Browse the repository at this point in the history
Fixes
  • Loading branch information
ftheirs authored Sep 8, 2022
2 parents 60a083e + a4da862 commit 36abba4
Show file tree
Hide file tree
Showing 17 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion app/Makefile.version
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ APPVERSION_M=2
# This is the `spec_version` field of `Runtime`
APPVERSION_N=0
# This is the patch version of this release
APPVERSION_P=5
APPVERSION_P=6
18 changes: 9 additions & 9 deletions app/src/parser_impl.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,18 @@ static uint8_t getMsgPackType(uint8_t byte)
return byte;
}

parser_error_t _readMapSize(parser_context_t *c, uint8_t *mapItems)
parser_error_t _readMapSize(parser_context_t *c, uint16_t *mapItems)
{
uint8_t byte = 0;
CHECK_ERROR(_readUInt8(c, &byte))

switch (getMsgPackType(byte)) {
case FIXMAP_0:
*mapItems = byte - FIXMAP_0;
*mapItems = (uint16_t) byte - FIXMAP_0;
break;

case MAP16:
CHECK_ERROR(_readUInt16(c, (uint16_t*)mapItems))
CHECK_ERROR(_readUInt16(c, mapItems))
break;

case MAP32:
Expand Down Expand Up @@ -198,7 +198,7 @@ parser_error_t _readString(parser_context_t *c, uint8_t *buff, uint16_t buffLen)
break;
}

if (strLen > buffLen) {
if (strLen >= buffLen) {
return parser_msgpack_str_too_big;
}
CHECK_ERROR(_readBytes(c, buff, strLen))
Expand Down Expand Up @@ -404,15 +404,15 @@ static parser_error_t _readAssetParams(parser_context_t *c, txn_asset_config *as
uint8_t available_params[MAX_PARAM_SIZE];
memset(available_params, 0xFF, MAX_PARAM_SIZE);

uint8_t paramsSize = 0;
uint16_t paramsSize = 0;
CHECK_ERROR(_readMapSize(c, &paramsSize))

if(paramsSize > MAX_PARAM_SIZE) {
return parser_unexpected_number_items;
}

uint8_t key[10] = {0};
for(uint8_t i = 0; i < paramsSize; i++) {
for(uint16_t i = 0; i < paramsSize; i++) {
CHECK_ERROR(_readString(c, key, sizeof(key)))

if (strncmp((char*)key, KEY_APARAMS_TOTAL, strlen(KEY_APARAMS_TOTAL)) == 0) {
Expand Down Expand Up @@ -615,10 +615,10 @@ parser_error_t _verifyAccounts(parser_context_t *c, uint8_t* num_accounts, uint8

parser_error_t _readStateSchema(parser_context_t *c, state_schema *schema)
{
uint8_t mapSize = 0;
uint16_t mapSize = 0;
CHECK_ERROR(_readMapSize(c, &mapSize))
uint8_t key[32];
for (size_t i = 0; i < mapSize; i++) {
for (uint16_t i = 0; i < mapSize; i++) {
CHECK_ERROR(_readString(c, key, sizeof(key)))
if (strncmp((char*)key, KEY_SCHEMA_NUI, sizeof(KEY_SCHEMA_NUI)) == 0) {
CHECK_ERROR(_readInteger(c, &schema->num_uint))
Expand Down Expand Up @@ -985,7 +985,7 @@ parser_error_t _readArray_args(parser_context_t *c, uint8_t args[][MAX_ARGLEN],

parser_error_t _read(parser_context_t *c, parser_tx_t *v)
{
uint8_t keyLen = 0;
uint16_t keyLen = 0;
CHECK_ERROR(initializeItemArray())

CHECK_ERROR(_readMapSize(c, &keyLen))
Expand Down
2 changes: 1 addition & 1 deletion app/src/parser_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ uint8_t _getTxNumItems();

parser_error_t _read(parser_context_t *c, parser_tx_t *v);

parser_error_t _readMapSize(parser_context_t *c, uint8_t *mapItems);
parser_error_t _readMapSize(parser_context_t *c, uint16_t *mapItems);
parser_error_t _readArraySize(parser_context_t *c, uint8_t *mapItems);
parser_error_t _readString(parser_context_t *c, uint8_t *buff, uint16_t buffLen);
parser_error_t _readInteger(parser_context_t *c, uint64_t* value);
Expand Down
6 changes: 3 additions & 3 deletions app/src/parser_txdef.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ typedef struct {
uint64_t total;
uint64_t decimals;
uint8_t default_frozen;
char unitname[8];
char assetname[32];
char url[32];
char unitname[9];
char assetname[33];
char url[33];
uint8_t metadata_hash[32];
uint8_t manager[32];
uint8_t reserve[32];
Expand Down
2 changes: 1 addition & 1 deletion deps/nanos-secure-sdk
2 changes: 1 addition & 1 deletion deps/nanosplus-secure-sdk
2 changes: 1 addition & 1 deletion deps/nanox-secure-sdk
12 changes: 6 additions & 6 deletions tests/parser_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ TEST(SCALE, EncodingUint8) {

parser_init(&ctx, buffer, bufferLen);

uint8_t mapItems {0};
uint16_t mapItems {0};
err = _readMapSize(&ctx, &mapItems);
EXPECT_EQ(err, parser_ok) << parser_getErrorDescription(err);
EXPECT_EQ(mapItems, 2);
Expand Down Expand Up @@ -127,7 +127,7 @@ TEST(SCALE, EncodingUint16) {

parser_init(&ctx, buffer, bufferLen);

uint8_t mapItems {0};
uint16_t mapItems {0};
err = _readMapSize(&ctx, &mapItems);
EXPECT_EQ(err, parser_ok) << parser_getErrorDescription(err);
EXPECT_EQ(mapItems, 2);
Expand Down Expand Up @@ -167,7 +167,7 @@ TEST(SCALE, EncodingUint32) {

parser_init(&ctx, buffer, bufferLen);

uint8_t mapItems {0};
uint16_t mapItems {0};
err = _readMapSize(&ctx, &mapItems);
EXPECT_EQ(err, parser_ok) << parser_getErrorDescription(err);
EXPECT_EQ(mapItems, 2);
Expand Down Expand Up @@ -207,7 +207,7 @@ TEST(SCALE, EncodingUint64) {

parser_init(&ctx, buffer, bufferLen);

uint8_t mapItems {0};
uint16_t mapItems {0};
err = _readMapSize(&ctx, &mapItems);
EXPECT_EQ(err, parser_ok) << parser_getErrorDescription(err);
EXPECT_EQ(mapItems, 2);
Expand Down Expand Up @@ -247,7 +247,7 @@ TEST(SCALE, EncodingString) {

parser_init(&ctx, buffer, bufferLen);

uint8_t mapItems {0};
uint16_t mapItems {0};
err = _readMapSize(&ctx, &mapItems);
EXPECT_EQ(err, parser_ok) << parser_getErrorDescription(err);
EXPECT_EQ(mapItems, 2);
Expand Down Expand Up @@ -286,7 +286,7 @@ TEST(SCALE, EncodingBoolean) {

parser_init(&ctx, buffer, bufferLen);

uint8_t mapItems {0};
uint16_t mapItems {0};
err = _readMapSize(&ctx, &mapItems);
EXPECT_EQ(err, parser_ok) << parser_getErrorDescription(err);
EXPECT_EQ(mapItems, 2);
Expand Down
2 changes: 1 addition & 1 deletion tests_zemu/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
"dependencies": {
"@zondax/ledger-algorand": "../js",
"@zondax/zemu": "^0.32.0"
"@zondax/zemu": "^0.33.1"
},
"devDependencies": {
"@types/jest": "^27.0.2",
Expand Down
Binary file modified tests_zemu/snapshots/s-mainmenu/00005.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/s-mainmenu/00011.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/sp-mainmenu/00005.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/sp-mainmenu/00011.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/x-mainmenu/00005.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/x-mainmenu/00011.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion tests_zemu/tests/big_transactions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@

// Wait until we are not in the main menu
await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot())
await sim.compareSnapshotsAndApprove('.', `${m.prefix.toLowerCase()}-sign_application_big`, 50000)
await sim.compareSnapshotsAndApprove('.', `${m.prefix.toLowerCase()}-sign_application_big`)

const signatureResponse = await signatureRequest
console.log(signatureResponse)
Expand Down
12 changes: 6 additions & 6 deletions tests_zemu/tests/standard.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ describe('Standard', function () {

// Wait until we are not in the main menu
await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot())
await sim.compareSnapshotsAndApprove('.', `${m.prefix.toLowerCase()}-sign_asset_freeze`,50000)
await sim.compareSnapshotsAndApprove('.', `${m.prefix.toLowerCase()}-sign_asset_freeze`)

const signatureResponse = await signatureRequest
console.log(signatureResponse)
Expand Down Expand Up @@ -215,7 +215,7 @@ describe('Standard', function () {

// Wait until we are not in the main menu
await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot())
await sim.compareSnapshotsAndApprove('.', `${m.prefix.toLowerCase()}-sign_asset_transfer`,50000)
await sim.compareSnapshotsAndApprove('.', `${m.prefix.toLowerCase()}-sign_asset_transfer`)

const signatureResponse = await signatureRequest
console.log(signatureResponse)
Expand Down Expand Up @@ -248,7 +248,7 @@ describe('Standard', function () {

// Wait until we are not in the main menu
await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot())
await sim.compareSnapshotsAndApprove('.', `${m.prefix.toLowerCase()}-sign_asset_config`,50000)
await sim.compareSnapshotsAndApprove('.', `${m.prefix.toLowerCase()}-sign_asset_config`)

const signatureResponse = await signatureRequest
console.log(signatureResponse)
Expand Down Expand Up @@ -281,7 +281,7 @@ describe('Standard', function () {

// Wait until we are not in the main menu
await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot())
await sim.compareSnapshotsAndApprove('.', `${m.prefix.toLowerCase()}-sign_keyreg`, 30000)
await sim.compareSnapshotsAndApprove('.', `${m.prefix.toLowerCase()}-sign_keyreg`)

const signatureResponse = await signatureRequest
console.log(signatureResponse)
Expand Down Expand Up @@ -314,7 +314,7 @@ describe('Standard', function () {

// Wait until we are not in the main menu
await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot())
await sim.compareSnapshotsAndApprove('.', `${m.prefix.toLowerCase()}-sign_payment`,50000)
await sim.compareSnapshotsAndApprove('.', `${m.prefix.toLowerCase()}-sign_payment`)

const signatureResponse = await signatureRequest
console.log(signatureResponse)
Expand Down Expand Up @@ -347,7 +347,7 @@ describe('Standard', function () {

// Wait until we are not in the main menu
await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot())
await sim.compareSnapshotsAndApprove('.', `${m.prefix.toLowerCase()}-sign_application`, 50000)
await sim.compareSnapshotsAndApprove('.', `${m.prefix.toLowerCase()}-sign_application`)

const signatureResponse = await signatureRequest
console.log(signatureResponse)
Expand Down

0 comments on commit 36abba4

Please sign in to comment.