Skip to content

Commit

Permalink
lib: do not set protobuf has_* field too early
Browse files Browse the repository at this point in the history
For two cases libcriu was setting the RPC protobuf field `has_*` before
checking if the given parameter is valid. This can lead to situations,
if the caller doesn't check the return value, that we pass as RPC struct
to CRIU which has the `has_*` protobuf field set to true, but does not
have a verified value (or non at all) set for the actual RPC entry.

Signed-off-by: Adrian Reber <[email protected]>
  • Loading branch information
adrianreber authored and avagin committed Jan 28, 2025
1 parent fc1dbc4 commit 343e731
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/c/criu.c
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,8 @@ int criu_set_parent_images(const char *path)

int criu_local_set_pre_dump_mode(criu_opts *opts, enum criu_pre_dump_mode mode)
{
opts->rpc->has_pre_dump_mode = true;
if (mode == CRIU_PRE_DUMP_SPLICE || mode == CRIU_PRE_DUMP_READ) {
opts->rpc->has_pre_dump_mode = true;
opts->rpc->pre_dump_mode = (CriuPreDumpMode)mode;
return 0;
}
Expand Down Expand Up @@ -1867,8 +1867,8 @@ void criu_set_pidfd_store_sk(int sk)

int criu_local_set_network_lock(criu_opts *opts, enum criu_network_lock_method method)
{
opts->rpc->has_network_lock = true;
if (method == CRIU_NETWORK_LOCK_IPTABLES || method == CRIU_NETWORK_LOCK_NFTABLES || method == CRIU_NETWORK_LOCK_SKIP) {
opts->rpc->has_network_lock = true;
opts->rpc->network_lock = (CriuNetworkLockMethod)method;
return 0;
}
Expand Down

0 comments on commit 343e731

Please sign in to comment.