Remove check for v length
This commit is contained in:
10
src/utils.c
10
src/utils.c
@@ -54,9 +54,7 @@ int local_strchr(char *string, char ch) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Almost like U4BE except that it takes `size` as a parameter.
|
||||
// The `strict` parameter defines whether we should throw in case of a length > 4.
|
||||
uint32_t u32_from_BE(uint8_t *in, uint8_t size, bool strict) {
|
||||
uint32_t u32_from_BE(uint8_t *in, uint8_t size) {
|
||||
switch (size) {
|
||||
case 0:
|
||||
return 0;
|
||||
@@ -66,13 +64,7 @@ uint32_t u32_from_BE(uint8_t *in, uint8_t size, bool strict) {
|
||||
return (in[0] << 8) | in[1];
|
||||
case 3:
|
||||
return (in[0] << 16) | (in[1] << 8) | in[2];
|
||||
case 4:
|
||||
return (in[0] << 24) | (in[1] << 16) | (in[2] << 8) | in[3];
|
||||
default:
|
||||
if (strict) {
|
||||
PRINTF("Unexpected format\n");
|
||||
THROW(EXCEPTION);
|
||||
}
|
||||
return (in[0] << 24) | (in[1] << 16) | (in[2] << 8) | in[3];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,9 +28,7 @@ void convertUint256BE(uint8_t* data, uint32_t length, uint256_t* target);
|
||||
|
||||
int local_strchr(char* string, char ch);
|
||||
|
||||
// Converts a list of bytes (in BE) of length `size` to a uint32_t. `strict` will make the function
|
||||
// throw if the size is > 4.
|
||||
uint32_t u32_from_BE(uint8_t* in, uint8_t size, bool strict);
|
||||
uint32_t u32_from_BE(uint8_t* in, uint8_t size);
|
||||
|
||||
bool uint256_to_decimal(const uint8_t* value, size_t value_len, char* out, size_t out_len);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user