RDB: handle encoding errors with rdbExitReportCorruptRDB().
Without such change, the diskless replicas, when loading RDB files from the socket will not abort when a broken RDB file gets loaded. This is potentially unsafe, because right now Redis is not able to guarantee that encoding errors are safe from the POV of memory corruptions (for instance the LZF library may not be safe against untrusted data?) so better to abort when the RDB file we are going to load is corrupted. Instead I/O errors are still returned to the caller without aborting, so that in case of short read the diskless replica can try again. Former-commit-id: 47feb2719ca7fd04e7e108ec1af0f777e536bf8a
This commit is contained in:
parent
bb9b8ee164
commit
3e75e77dcd
@ -278,8 +278,8 @@ void *rdbLoadIntegerObject(rio *rdb, int enctype, int flags, size_t *lenptr) {
|
|||||||
v = enc[0]|(enc[1]<<8)|(enc[2]<<16)|(enc[3]<<24);
|
v = enc[0]|(enc[1]<<8)|(enc[2]<<16)|(enc[3]<<24);
|
||||||
val = (int32_t)v;
|
val = (int32_t)v;
|
||||||
} else {
|
} else {
|
||||||
val = 0; /* anti-warning */
|
|
||||||
rdbExitReportCorruptRDB("Unknown RDB integer encoding type %d",enctype);
|
rdbExitReportCorruptRDB("Unknown RDB integer encoding type %d",enctype);
|
||||||
|
return nullptr; /* Never reached. */
|
||||||
}
|
}
|
||||||
if (plain || sds) {
|
if (plain || sds) {
|
||||||
char buf[LONG_STR_SIZE], *p;
|
char buf[LONG_STR_SIZE], *p;
|
||||||
@ -497,6 +497,7 @@ void *rdbGenericLoadStringObject(rio *rdb, int flags, size_t *lenptr) {
|
|||||||
return rdbLoadLzfStringObject(rdb,flags,lenptr);
|
return rdbLoadLzfStringObject(rdb,flags,lenptr);
|
||||||
default:
|
default:
|
||||||
rdbExitReportCorruptRDB("Unknown RDB string encoding type %d",len);
|
rdbExitReportCorruptRDB("Unknown RDB string encoding type %d",len);
|
||||||
|
return nullptr; /* Never reached. */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user