Merge pull request #4908 from soloestoy/aof-rdb-preamble-compatible-checksum-no

AOF & RDB: be compatible with rdbchecksum no
This commit is contained in:
Salvatore Sanfilippo 2018-05-23 17:11:00 +02:00 committed by GitHub
commit 1ab3c82375
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2027,16 +2027,18 @@ int rdbLoadRio(rio *rdb, rdbSaveInfo *rsi) {
lru_idle = -1;
}
/* Verify the checksum if RDB version is >= 5 */
if (rdbver >= 5 && server.rdb_checksum) {
if (rdbver >= 5) {
uint64_t cksum, expected = rdb->cksum;
if (rioRead(rdb,&cksum,8) == 0) goto eoferr;
memrev64ifbe(&cksum);
if (cksum == 0) {
serverLog(LL_WARNING,"RDB file was saved with checksum disabled: no check performed.");
} else if (cksum != expected) {
serverLog(LL_WARNING,"Wrong RDB checksum. Aborting now.");
rdbExitReportCorruptRDB("RDB CRC error");
if (server.rdb_checksum) {
memrev64ifbe(&cksum);
if (cksum == 0) {
serverLog(LL_WARNING,"RDB file was saved with checksum disabled: no check performed.");
} else if (cksum != expected) {
serverLog(LL_WARNING,"Wrong RDB checksum. Aborting now.");
rdbExitReportCorruptRDB("RDB CRC error");
}
}
}
return C_OK;