mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-22 16:18:28 -05:00
Added functions support to redis-check-rdb (#10154)
The PR added the missing verification for functions on redis-check-rdb. The verification only verifies the rdb structure and does not try to load the functions code and verify more advance checks (like compilation of the function code).
This commit is contained in:
parent
c4b788230c
commit
9c60292250
@ -2747,7 +2747,10 @@ void rdbLoadProgressCallback(rio *r, const void *buf, size_t len) {
|
|||||||
/* Save the given functions_ctx to the rdb.
|
/* Save the given functions_ctx to the rdb.
|
||||||
* The err output parameter is optional and will be set with relevant error
|
* The err output parameter is optional and will be set with relevant error
|
||||||
* message on failure, it is the caller responsibility to free the error
|
* message on failure, it is the caller responsibility to free the error
|
||||||
* message on failure. */
|
* message on failure.
|
||||||
|
*
|
||||||
|
* The lib_ctx argument is also optional. If NULL is given, only verify rdb
|
||||||
|
* structure with out performing the actual functions loading. */
|
||||||
int rdbFunctionLoad(rio *rdb, int ver, functionsLibCtx* lib_ctx, int rdbflags, sds *err) {
|
int rdbFunctionLoad(rio *rdb, int ver, functionsLibCtx* lib_ctx, int rdbflags, sds *err) {
|
||||||
UNUSED(ver);
|
UNUSED(ver);
|
||||||
sds name = NULL;
|
sds name = NULL;
|
||||||
@ -2782,12 +2785,14 @@ int rdbFunctionLoad(rio *rdb, int ver, functionsLibCtx* lib_ctx, int rdbflags, s
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (lib_ctx) {
|
||||||
if (functionsCreateWithLibraryCtx(name, engine_name, desc, blob, rdbflags & RDBFLAGS_ALLOW_DUP, &error, lib_ctx) != C_OK) {
|
if (functionsCreateWithLibraryCtx(name, engine_name, desc, blob, rdbflags & RDBFLAGS_ALLOW_DUP, &error, lib_ctx) != C_OK) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
error = sdsnew("Failed creating the library");
|
error = sdsnew("Failed creating the library");
|
||||||
}
|
}
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
res = C_OK;
|
res = C_OK;
|
||||||
|
|
||||||
|
@ -303,6 +303,14 @@ int redis_check_rdb(char *rdbfilename, FILE *fp) {
|
|||||||
robj *o = rdbLoadCheckModuleValue(&rdb,name);
|
robj *o = rdbLoadCheckModuleValue(&rdb,name);
|
||||||
decrRefCount(o);
|
decrRefCount(o);
|
||||||
continue; /* Read type again. */
|
continue; /* Read type again. */
|
||||||
|
} else if (type == RDB_OPCODE_FUNCTION) {
|
||||||
|
sds err = NULL;
|
||||||
|
if (rdbFunctionLoad(&rdb, rdbver, NULL, 0, &err) != C_OK) {
|
||||||
|
rdbCheckError("Failed loading library, %s", err);
|
||||||
|
sdsfree(err);
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
} else {
|
} else {
|
||||||
if (!rdbIsObjectType(type)) {
|
if (!rdbIsObjectType(type)) {
|
||||||
rdbCheckError("Invalid object type: %d", type);
|
rdbCheckError("Invalid object type: %d", type);
|
||||||
|
Loading…
Reference in New Issue
Block a user