Skip to content

Commit

Permalink
Add length check of ED key
Browse files Browse the repository at this point in the history
  • Loading branch information
aveenismail committed Sep 4, 2024
1 parent 4efee1f commit e23eaa7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions common/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,12 @@ bool read_ed25519_key(uint8_t *in, size_t in_len, uint8_t *out,
uint8_t decoded[128];
size_t decoded_len = sizeof(decoded);

if (memcmp(in, PEM_private_header, 28) != 0 ||
memcmp(in + in_len - 26, PEM_private_trailer, 25) != 0) {
if(in_len < (sizeof(PEM_private_header) + sizeof(PEM_private_trailer)-3)) {
return false;
}
if (memcmp(in, PEM_private_header, sizeof(PEM_private_header)-1) != 0 ||
memcmp(in + in_len - sizeof(PEM_private_header), PEM_private_trailer,
sizeof(PEM_private_header) - 2) != 0) {
return false;
}

Expand Down

0 comments on commit e23eaa7

Please sign in to comment.