diff options
author | kaotisk <kaotisk@arching-kaos.org> | 2025-04-29 05:11:39 +0300 |
---|---|---|
committer | kaotisk <kaotisk@arching-kaos.org> | 2025-04-29 05:11:39 +0300 |
commit | 977b8db0d5fb74e5c5d0b1912ef68986ae201038 (patch) | |
tree | 1eece395b11eb8f497869f8da7be1bff6acd4554 | |
parent | 0339ddb3a21dc4fa5544e279a4f3a2b34f96548c (diff) | |
download | arching-kaos-tools-977b8db0d5fb74e5c5d0b1912ef68986ae201038.tar.gz arching-kaos-tools-977b8db0d5fb74e5c5d0b1912ef68986ae201038.tar.bz2 arching-kaos-tools-977b8db0d5fb74e5c5d0b1912ef68986ae201038.zip |
Fixes
-rw-r--r-- | c_implementation/src/ak_fs.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/c_implementation/src/ak_fs.c b/c_implementation/src/ak_fs.c index 6a7636a..5643276 100644 --- a/c_implementation/src/ak_fs.c +++ b/c_implementation/src/ak_fs.c @@ -310,16 +310,15 @@ int ak_fs_cat_file_from_root_hash(sha512sum* rh) return 1; } is_chunk = true; - free(fullpath); } if ( !is_chunk ) { - char buffer[258]; - size_t bytes_read = fread(&buffer, sizeof(buffer), 1, fd); - fclose(fd); + char buffer[258] = {0}; + size_t bytes_read = fread(&buffer, 1, sizeof(buffer), fd); if ( bytes_read < sizeof(buffer) ) { ak_log_error(__func__, "File is smaller than expected. Wrong format?"); + fclose(fd); return 2; } if ( buffer[128] != '\n' || buffer[257] != '\n' ) @@ -349,6 +348,7 @@ int ak_fs_cat_file_from_root_hash(sha512sum* rh) if (stat(fullpath, &sb) == -1) { perror("stat"); fclose(fd); + free(fullpath); return 2; } char buffer[(long long) sb.st_size+1]; @@ -357,6 +357,7 @@ int ak_fs_cat_file_from_root_hash(sha512sum* rh) buffer[sizeof(buffer)-1] = '\0'; printf("%s", buffer); } + free(fullpath); return 0; } |