Unverified Commit 0a2f7883 authored by Binbin's avatar Binbin Committed by GitHub
Browse files

redis-check-rdb add when_opcode check for module aux (#10859)

In #9199, we add a `goto eoferr` in when_opcode check,
this means that if the when_opcode check fails, we will
abort the rdb loading, but this not reflected in the
rdb-check tool. So someone can modify when_opcode to make
rdb load fail, but rdb-check will report OK. Just a cleanup
or a code consistency issue.
```
serverLog: # Internal error in RDB reading offset 0, function at rdb.c:3055 -> bad when_opcode
[offset 0] Checking RDB file dump.rdb
[offset 109] \o/ RDB looks OK! \o/
```

Plus a minor memory leak fix like #9860, note that it will
exit immediately after the eoferr, so it is not strictly a
leak, so it is also a small cleanup.
parent d4595dd9
...@@ -283,7 +283,10 @@ int redis_check_rdb(char *rdbfilename, FILE *fp) { ...@@ -283,7 +283,10 @@ int redis_check_rdb(char *rdbfilename, FILE *fp) {
robj *auxkey, *auxval; robj *auxkey, *auxval;
rdbstate.doing = RDB_CHECK_DOING_READ_AUX; rdbstate.doing = RDB_CHECK_DOING_READ_AUX;
if ((auxkey = rdbLoadStringObject(&rdb)) == NULL) goto eoferr; if ((auxkey = rdbLoadStringObject(&rdb)) == NULL) goto eoferr;
if ((auxval = rdbLoadStringObject(&rdb)) == NULL) goto eoferr; if ((auxval = rdbLoadStringObject(&rdb)) == NULL) {
decrRefCount(auxkey);
goto eoferr;
}
rdbCheckInfo("AUX FIELD %s = '%s'", rdbCheckInfo("AUX FIELD %s = '%s'",
(char*)auxkey->ptr, (char*)auxval->ptr); (char*)auxkey->ptr, (char*)auxval->ptr);
...@@ -297,6 +300,10 @@ int redis_check_rdb(char *rdbfilename, FILE *fp) { ...@@ -297,6 +300,10 @@ int redis_check_rdb(char *rdbfilename, FILE *fp) {
if ((moduleid = rdbLoadLen(&rdb,NULL)) == RDB_LENERR) goto eoferr; if ((moduleid = rdbLoadLen(&rdb,NULL)) == RDB_LENERR) goto eoferr;
if ((when_opcode = rdbLoadLen(&rdb,NULL)) == RDB_LENERR) goto eoferr; if ((when_opcode = rdbLoadLen(&rdb,NULL)) == RDB_LENERR) goto eoferr;
if ((when = rdbLoadLen(&rdb,NULL)) == RDB_LENERR) goto eoferr; if ((when = rdbLoadLen(&rdb,NULL)) == RDB_LENERR) goto eoferr;
if (when_opcode != RDB_MODULE_OPCODE_UINT) {
rdbCheckError("bad when_opcode");
goto err;
}
char name[10]; char name[10];
moduleTypeNameByID(name,moduleid); moduleTypeNameByID(name,moduleid);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment