Fix: handle file opening errors

This commit is contained in:
Dorian Zedler 2022-07-12 22:37:54 +02:00
parent 2a6bb4354e
commit 21d351c7e2
Signed by: dorian
GPG key ID: 989DE36109AFA354
2 changed files with 1 additions and 2 deletions

View file

@ -4,7 +4,6 @@ bool open_file(const char* path, FILE** file, struct stat* file_stat) {
(*file) = fopen(path, "r");
if ((*file) == NULL) {
printf("Fopen error: %d\n", errno);
fclose((*file));
return false;
}

View file

@ -47,7 +47,7 @@ void md2_hash_2(size_t len, const uint8_t buf[len], uint8_t out[16]) {
FILE* file;
struct stat file_stat;
if (!open_file((char*)buf, &file, &file_stat)) {
fprintf(stderr, "Error opening the file!");
fprintf(stderr, "Error opening the file!\n");
return;
}