From 4d45ac307d164547abfef385f81ff4fffe811925 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Wed, 12 Aug 2026 13:06:54 -0700 Subject: [PATCH] mempolicy: treat empty nodes as unset An empty "nodes" string is parsed as a non-NULL empty string, so cpuset_string_to_bitmask() returns a NULL bitmask of size 0, and the subsequent memcpy(dst, NULL, 0) violates memcpy's nonnull constraint. Guard with is_empty_string(), the same way libcrun_set_cpu_affinity_from_string() does. Fixes: https://github.com/containers/crun/issues/2181 Signed-off-by: Kir Kolyshkin Co-Authored-By: Claude Opus 5 --- src/libcrun/mempolicy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcrun/mempolicy.c b/src/libcrun/mempolicy.c index abaf045a3d..9a3b48d323 100644 --- a/src/libcrun/mempolicy.c +++ b/src/libcrun/mempolicy.c @@ -130,7 +130,7 @@ libcrun_set_mempolicy (runtime_spec_schema_config_schema *def, libcrun_error_t * } /* kernel will take care of validating the nodes */ - if (memory_policy->nodes) + if (! is_empty_string (memory_policy->nodes)) { cleanup_free char *bitmask = NULL; size_t bitmask_size;