mirror of
https://github.com/checkpoint-restore/criu
synced 2025-09-02 07:15:31 +00:00
scripts: Add ACT_MAX limit and make @action_names being const
@action_names is rather a const array, so make sure we never access some data outside of it defining its size. Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
committed by
Pavel Emelyanov
parent
02d9bd1093
commit
5676383729
@@ -11,7 +11,7 @@
|
|||||||
#include "cr-service.h"
|
#include "cr-service.h"
|
||||||
#include "action-scripts.h"
|
#include "action-scripts.h"
|
||||||
|
|
||||||
static char *action_names[] = {
|
static const char *action_names[ACT_MAX] = {
|
||||||
[ ACT_POST_DUMP ] = "post-dump",
|
[ ACT_POST_DUMP ] = "post-dump",
|
||||||
[ ACT_POST_RESTORE ] = "post-restore",
|
[ ACT_POST_RESTORE ] = "post-restore",
|
||||||
[ ACT_NET_LOCK ] = "network-lock",
|
[ ACT_NET_LOCK ] = "network-lock",
|
||||||
@@ -24,7 +24,7 @@ int run_scripts(enum script_actions act)
|
|||||||
struct script *script;
|
struct script *script;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
char image_dir[PATH_MAX];
|
char image_dir[PATH_MAX];
|
||||||
char *action = action_names[act];
|
const char *action = action_names[act];
|
||||||
|
|
||||||
pr_debug("Running %s scripts\n", action);
|
pr_debug("Running %s scripts\n", action);
|
||||||
|
|
||||||
@@ -42,7 +42,7 @@ int run_scripts(enum script_actions act)
|
|||||||
list_for_each_entry(script, &opts.scripts, node) {
|
list_for_each_entry(script, &opts.scripts, node) {
|
||||||
if (script->path == SCRIPT_RPC_NOTIFY) {
|
if (script->path == SCRIPT_RPC_NOTIFY) {
|
||||||
pr_debug("\tRPC\n");
|
pr_debug("\tRPC\n");
|
||||||
ret |= send_criu_rpc_script(act, action, script->arg);
|
ret |= send_criu_rpc_script(act, (char *)action, script->arg);
|
||||||
} else {
|
} else {
|
||||||
pr_debug("\t[%s]\n", script->path);
|
pr_debug("\t[%s]\n", script->path);
|
||||||
ret |= system(script->path);
|
ret |= system(script->path);
|
||||||
|
@@ -10,11 +10,13 @@ struct script {
|
|||||||
#define SCRIPT_RPC_NOTIFY (char *)0x1
|
#define SCRIPT_RPC_NOTIFY (char *)0x1
|
||||||
|
|
||||||
enum script_actions {
|
enum script_actions {
|
||||||
ACT_POST_DUMP,
|
ACT_POST_DUMP = 0,
|
||||||
ACT_POST_RESTORE,
|
ACT_POST_RESTORE = 1,
|
||||||
ACT_NET_LOCK,
|
ACT_NET_LOCK = 2,
|
||||||
ACT_NET_UNLOCK,
|
ACT_NET_UNLOCK = 3,
|
||||||
ACT_SETUP_NS,
|
ACT_SETUP_NS = 4,
|
||||||
|
|
||||||
|
ACT_MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
extern int add_script(char *path, int arg);
|
extern int add_script(char *path, int arg);
|
||||||
|
Reference in New Issue
Block a user