From 62b961d64ce9d4357ea0becfdd473dfa093fb970 Mon Sep 17 00:00:00 2001 From: Adam Julis Date: Wed, 15 Jan 2025 14:27:20 +0100 Subject: [PATCH] conf: check size of secret file for secret object MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since the empty file with a .base64 value wasn't recognized during the loading process (starting of libvirtd), attempting to get a value for the UUID resulted in an undefined error. This patch resolves the issue by checking the size of the file and ensuring that the stored value is as expected (NULL). Reviewed-by: Daniel P. Berrangé Signed-off-by: Adam Julis --- src/conf/virsecretobj.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/conf/virsecretobj.c b/src/conf/virsecretobj.c index 455798d414..66270e2751 100644 --- a/src/conf/virsecretobj.c +++ b/src/conf/virsecretobj.c @@ -836,6 +836,11 @@ virSecretLoadValue(virSecretObj *obj) goto cleanup; } + if (st.st_size < 1) { + ret = 0; + goto cleanup; + } + contents = g_new0(char, st.st_size + 1); if (saferead(fd, contents, st.st_size) != st.st_size) {