Skip to content

Commit

Permalink
Now use buf_shrink_expand in parse_der_value
Browse files Browse the repository at this point in the history
  • Loading branch information
apaillier-ledger committed Feb 20, 2025
1 parent 39b14a8 commit 65f36d2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/tlv.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "tlv.h"
#include "os_print.h" // PRINTF
#include "read.h" // read_u32_be
#include "utils.h" // buf_shrink_expand

typedef enum { TLV_STATE_TAG, TLV_STATE_LENGTH, TLV_STATE_VALUE } e_tlv_state;

Expand Down Expand Up @@ -30,8 +31,7 @@ static bool parse_der_value(const uint8_t *payload,
PRINTF("Unexpectedly long DER-encoded value (%u bytes)\n", byte_length);
return false;
}
memset(buf, 0, (sizeof(buf) - byte_length));
memcpy(buf + (sizeof(buf) - byte_length), &payload[*offset], byte_length);
buf_shrink_expand(&payload[*offset], byte_length, buf, sizeof(buf));
*value = read_u32_be(buf, 0);
*offset += byte_length;
} else { // short form
Expand Down

0 comments on commit 65f36d2

Please sign in to comment.