Skip to content
Snippets Groups Projects
Commit cb42e7e0 authored by Jan Kadlec's avatar Jan Kadlec
Browse files

Updated db magic bytes.

- Magic is now checked before CRC, this should prevent confusion when loading old dumps.
parent b5b3ffec
No related branches found
No related tags found
No related merge requests found
......@@ -38,7 +38,7 @@ enum {
};
/*! \brief Magic identifier: { "knot", maj_ver, min_ver, revision } */
#define MAGIC_BYTES {'k', 'n', 'o', 't', '1', '0', '0'}
#define MAGIC_BYTES {'k', 'n', 'o', 't', '1', '0', '3'}
/*!
* \brief Dumps given zone to binary file.
......
......@@ -914,16 +914,7 @@ int knot_zload_open(zloader_t **dst, const char *filename)
/* Free some value and close the CRC file */
free(crc_path);
close(f_crc);
/* Compare calculated and read CRCs. */
if (crc_from_file != crc_calculated) {
dbg_zload("knot_zload_open: CRC failed for "
"file '%s'\n",
filename);
fclose(f);
return KNOT_ECRC;
}
/* Check magic sequence. */
static const uint8_t MAGIC[MAGIC_LENGTH] = MAGIC_BYTES;
if (!knot_check_magic(f, MAGIC, MAGIC_LENGTH)) {
......@@ -935,6 +926,15 @@ int knot_zload_open(zloader_t **dst, const char *filename)
return KNOT_EMALF; // Illegal byte sequence (POSIX.1, C99)
}
/* Compare calculated and read CRCs. */
if (crc_from_file != crc_calculated) {
dbg_zload("knot_zload_open: CRC failed for "
"file '%s'\n",
filename);
fclose(f);
return KNOT_ECRC;
}
/* Read source file length. */
uint32_t sflen = 0;
if (!fread_wrapper(&sflen, 1, sizeof(uint32_t), 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