]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
crypto: replace stat() with access() for credential checks
authorDaniel P. Berrangé <berrange@redhat.com>
Fri, 1 Aug 2025 14:06:13 +0000 (15:06 +0100)
committerDaniel P. Berrangé <berrange@redhat.com>
Mon, 3 Nov 2025 10:45:55 +0000 (10:45 +0000)
Readability of the credential files is what matters for our usage,
so access() is more appropriate than stat().

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
crypto/tlscreds.c

index 9e59594d673218bc78a3a71c3b6e15fc1843a51c..208a7e6d8fb534fed9dada67a1ff8d30fa356312 100644 (file)
@@ -100,7 +100,6 @@ qcrypto_tls_creds_get_path(QCryptoTLSCreds *creds,
                            char **cred,
                            Error **errp)
 {
-    struct stat sb;
     int ret = -1;
 
     if (!creds->dir) {
@@ -114,7 +113,7 @@ qcrypto_tls_creds_get_path(QCryptoTLSCreds *creds,
 
     *cred = g_strdup_printf("%s/%s", creds->dir, filename);
 
-    if (stat(*cred, &sb) < 0) {
+    if (access(*cred, R_OK) < 0) {
         if (errno == ENOENT && !required) {
             ret = 0;
         } else {