Skip to content
Snippets Groups Projects
Commit 8ae602e0 authored by Marek Vavrusa's avatar Marek Vavrusa
Browse files

Resolved forgotten fprintf and error message when compiled zone file is empty.

parent 0da5ad1c
No related branches found
No related tags found
No related merge requests found
......@@ -66,8 +66,8 @@ static inline int fread_safe_from_file(void *dst,
{
int rc = fread(dst, size, n, fp);
if (rc != n) {
fprintf(stderr, "fread: invalid read %d (expected %zu)\n", rc,
n);
dbg_zload("fread_safe_from_file: invalid read %d (exp. %zu)\n",
rc, n);
}
return rc == n;
......@@ -856,6 +856,15 @@ int knot_zload_open(zloader_t **dst, const char *filename)
return KNOT_EFEWDATA; // No such file or directory (POSIX.1)
}
/* Calculate file size. */
fseek(f, 0L, SEEK_END);
size_t file_size = ftell(f);
fseek(f, 0L, SEEK_SET);
if (file_size < MAGIC_LENGTH) {
fclose(f);
return KNOT_EFEWDATA;
}
/* Calculate CRC and compare with filename.crc file */
unsigned long crc_calculated = calculate_crc(f);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment