Skip to content

Commit f7172d0

Browse files
authored
Merge pull request #185 from cosmos/dev
Dev
2 parents 3956512 + 1548a48 commit f7172d0

File tree

48 files changed

+24
-11
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+24
-11
lines changed

.github/workflows/main.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,6 @@ jobs:
1616
runs-on: ${{ github.repository_owner == 'zondax' && 'zondax-runners' || 'ubuntu-latest' }}
1717
has-rust: false
1818
has-nanos: false
19-
node-version: '22'
19+
node-version: '22'
20+
permissions:
21+
contents: write # Required for creating releases

app/Makefile.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ APPVERSION_M=2
33
# This is the `spec_version` field of `Runtime`
44
APPVERSION_N=38
55
# This is the patch version of this release
6-
APPVERSION_P=8
6+
APPVERSION_P=9

app/src/apdu_handler.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,12 +221,23 @@ __Z_INLINE void handleSign(volatile uint32_t *flags, volatile uint32_t *tx,
221221
THROW(APDU_CODE_DATA_INVALID);
222222
}
223223

224-
if (rx < VIEW_ADDRESS_OFFSET_SECP256K1) {
224+
// Put address in output buffer, we will use it to confirm source address
225+
zxerr_t zxerr = app_fill_address();
226+
if (zxerr != zxerr_ok) {
227+
*tx = 0;
228+
THROW(APDU_CODE_DATA_INVALID);
229+
}
230+
231+
// Safety: ensure response contains more than just pubkey
232+
if (action_addrResponseLen <= PK_LEN_SECP256K1) {
233+
*tx = 0;
225234
THROW(APDU_CODE_DATA_INVALID);
226235
}
236+
227237
parser_tx_obj.tx_json.own_addr =
228238
(const char *)(G_io_apdu_buffer + VIEW_ADDRESS_OFFSET_SECP256K1);
229-
parser_tx_obj.tx_json.own_addr_len = rx - VIEW_ADDRESS_OFFSET_SECP256K1;
239+
parser_tx_obj.tx_json.own_addr_len =
240+
action_addrResponseLen - PK_LEN_SECP256K1;
230241
const char *error_msg = tx_parse(sign_type);
231242
if (error_msg != NULL) {
232243
const int error_msg_length = strnlen(error_msg, sizeof(G_io_apdu_buffer));

app/src/json/json_parser.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ parser_error_t array_get_element_count(const parsed_json_t *json,
9494
}
9595

9696
*number_elements = 0;
97-
if (array_token_index > json->numberOfTokens) {
97+
if (array_token_index >= json->numberOfTokens) {
9898
return parser_no_data;
9999
}
100100

@@ -128,7 +128,7 @@ parser_error_t array_get_nth_element(const parsed_json_t *json,
128128
return parser_unexpected_value;
129129
}
130130

131-
if (array_token_index > json->numberOfTokens) {
131+
if (array_token_index >= json->numberOfTokens) {
132132
return parser_no_data;
133133
}
134134

@@ -167,7 +167,7 @@ parser_error_t object_get_element_count(const parsed_json_t *json,
167167
}
168168

169169
*element_count = 0;
170-
if (object_token_index > json->numberOfTokens) {
170+
if (object_token_index >= json->numberOfTokens) {
171171
return parser_no_data;
172172
}
173173

@@ -203,7 +203,7 @@ parser_error_t object_get_nth_key(const parsed_json_t *json,
203203
}
204204

205205
*token_index = object_token_index;
206-
if (object_token_index > json->numberOfTokens) {
206+
if (object_token_index >= json->numberOfTokens) {
207207
return parser_no_data;
208208
}
209209

@@ -242,7 +242,7 @@ parser_error_t object_get_nth_value(const parsed_json_t *json,
242242
return parser_unexpected_value;
243243
}
244244

245-
if (object_token_index > json->numberOfTokens) {
245+
if (object_token_index >= json->numberOfTokens) {
246246
return parser_no_data;
247247
}
248248

@@ -260,7 +260,7 @@ parser_error_t object_get_value(const parsed_json_t *json,
260260
return parser_unexpected_value;
261261
}
262262

263-
if (object_token_index > json->numberOfTokens) {
263+
if (object_token_index >= json->numberOfTokens) {
264264
return parser_no_data;
265265
}
266266

app/src/tx_display.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ parser_error_t tx_display_translation(char *dst, uint16_t dstLen, char *src,
694694
}
695695

696696
if (src[srcLen - 1] == ' ' || src[srcLen - 1] == '@') {
697-
if (src[dstLen - 1] + 1 > dstLen) {
697+
if (count >= dstLen) {
698698
return parser_unexpected_value;
699699
}
700700
ASSERT_PTR_BOUNDS(count, dstLen);
42 Bytes
-51 Bytes
-1.82 KB
-51 Bytes
-1.82 KB

0 commit comments

Comments
 (0)