aboutsummaryrefslogtreecommitdiff
path: root/c_implementation/src
diff options
context:
space:
mode:
authorkaotisk <kaotisk@arching-kaos.org>2025-04-29 05:11:39 +0300
committerkaotisk <kaotisk@arching-kaos.org>2025-04-29 19:31:25 +0300
commit606f4e09cee1cde4b1b8f41e71c166cbf79d21c5 (patch)
treecc1d20f66841c529783aec145df8a1d3aaa99439 /c_implementation/src
parent20256cca51430c581aabd9661f97dbaed46725d3 (diff)
downloadarching-kaos-tools-606f4e09cee1cde4b1b8f41e71c166cbf79d21c5.tar.gz
arching-kaos-tools-606f4e09cee1cde4b1b8f41e71c166cbf79d21c5.tar.bz2
arching-kaos-tools-606f4e09cee1cde4b1b8f41e71c166cbf79d21c5.zip
Fixes
Diffstat (limited to 'c_implementation/src')
-rw-r--r--c_implementation/src/ak_fs.c9
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;
}