Skip to content

Commit bd56838

Browse files
Merge pull request #295 from LedgerHQ/fix/bigger_printable_amount_size
[add] Extending the amount buffer from 30 to 50 bytes
2 parents 1f4ed3b + 66ac35b commit bd56838

File tree

4 files changed

+25
-23
lines changed

4 files changed

+25
-23
lines changed

src/handle_check_address.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ int handle_check_address(check_address_parameters_t* params, chain_config_t* cha
1616
}
1717

1818
uint8_t i;
19-
uint8_t* bip32_path_ptr = params->address_parameters;
19+
const uint8_t* bip32_path_ptr = params->address_parameters;
2020
uint8_t bip32PathLength = *(bip32_path_ptr++);
2121
cx_sha3_t local_sha3;
2222

src/swap_lib_calls.h

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,43 +11,45 @@
1111

1212
#define GET_PRINTABLE_AMOUNT 4
1313

14+
#define MAX_PRINTABLE_AMOUNT_SIZE 50
15+
1416
// structure that should be send to specific coin application to get address
1517
typedef struct check_address_parameters_s {
1618
// IN
17-
unsigned char* coin_configuration;
18-
unsigned char coin_configuration_length;
19+
const unsigned char* const coin_configuration;
20+
const unsigned char coin_configuration_length;
1921
// serialized path, segwit, version prefix, hash used, dictionary etc.
2022
// fields and serialization format depends on spesific coin app
21-
unsigned char* address_parameters;
22-
unsigned char address_parameters_length;
23-
char* address_to_check;
24-
char* extra_id_to_check;
23+
const unsigned char* const address_parameters;
24+
const unsigned char address_parameters_length;
25+
const char* const address_to_check;
26+
const char* const extra_id_to_check;
2527
// OUT
2628
int result;
2729
} check_address_parameters_t;
2830

2931
// structure that should be send to specific coin application to get printable amount
3032
typedef struct get_printable_amount_parameters_s {
3133
// IN
32-
unsigned char* coin_configuration;
33-
unsigned char coin_configuration_length;
34-
unsigned char* amount;
35-
unsigned char amount_length;
36-
bool is_fee;
34+
const unsigned char* const coin_configuration;
35+
const unsigned char coin_configuration_length;
36+
const unsigned char* const amount;
37+
const unsigned char amount_length;
38+
const bool is_fee;
3739
// OUT
38-
char printable_amount[30];
40+
char printable_amount[MAX_PRINTABLE_AMOUNT_SIZE];
3941
// int result;
4042
} get_printable_amount_parameters_t;
4143

4244
typedef struct create_transaction_parameters_s {
43-
unsigned char* coin_configuration;
44-
unsigned char coin_configuration_length;
45-
unsigned char* amount;
46-
unsigned char amount_length;
47-
unsigned char* fee_amount;
48-
unsigned char fee_amount_length;
49-
char* destination_address;
50-
char* destination_address_extra_id;
45+
const unsigned char* const coin_configuration;
46+
const unsigned char coin_configuration_length;
47+
const unsigned char* const amount;
48+
const unsigned char amount_length;
49+
const unsigned char* const fee_amount;
50+
const unsigned char fee_amount_length;
51+
const char* const destination_address;
52+
const char* const destination_address_extra_id;
5153
} create_transaction_parameters_t;
5254

5355
#endif // _SWAP_LIB_CALLS_H_

src/utils.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ void amountToString(const uint8_t *amount,
138138
out_buffer[out_buffer_size - 1] = '\0';
139139
}
140140

141-
bool parse_swap_config(uint8_t *config, uint8_t config_len, char *ticker, uint8_t *decimals) {
141+
bool parse_swap_config(const uint8_t *config, uint8_t config_len, char *ticker, uint8_t *decimals) {
142142
uint8_t ticker_len, offset = 0;
143143
if (config_len == 0) {
144144
return false;

src/utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ void amountToString(const uint8_t* amount,
3939
char* out_buffer,
4040
size_t out_buffer_size);
4141

42-
bool parse_swap_config(uint8_t* config, uint8_t config_len, char* ticker, uint8_t* decimals);
42+
bool parse_swap_config(const uint8_t* config, uint8_t config_len, char* ticker, uint8_t* decimals);
4343

4444
#endif // _UTILS_H_

0 commit comments

Comments
 (0)