]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: check size of secret file for secret object
authorAdam Julis <ajulis@redhat.com>
Wed, 15 Jan 2025 13:27:20 +0000 (14:27 +0100)
committerDaniel P. Berrangé <berrange@redhat.com>
Tue, 28 Jan 2025 11:08:58 +0000 (11:08 +0000)
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é <berrange@redhat.com>
Signed-off-by: Adam Julis <ajulis@redhat.com>
src/conf/virsecretobj.c

index 455798d414c674a3df4c2dd346325a64a724a639..66270e2751a7a337c41dc3e6ac59e1d89f47ee8b 100644 (file)
@@ -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) {