Skip to content

Commit

Permalink
Add error checking in pem.c
Browse files Browse the repository at this point in the history
  • Loading branch information
guanzhi committed Sep 26, 2023
1 parent 551d493 commit c8e1607
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/pem.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,15 @@ int pem_read(FILE *fp, const char *name, uint8_t *data, size_t *datalen, size_t
snprintf(end_line, sizeof(end_line), "-----END %s-----", name);

if (feof(fp)) {
error_print();
return 0;
}

if (!fgets(line, sizeof(line), fp)) {
if (feof(fp))
if (feof(fp)) {
error_print();
return 0;
else {
} else {
error_print();
return -1;
}
Expand Down

0 comments on commit c8e1607

Please sign in to comment.