From: Daniel P. Berrangé Date: Fri, 1 Aug 2025 14:06:13 +0000 (+0100) Subject: crypto: replace stat() with access() for credential checks X-Git-Tag: v10.2.0-rc1~24^2~18 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2114ae9faaabe4ff1c455811bb38085324af17b7;p=thirdparty%2Fqemu.git crypto: replace stat() with access() for credential checks Readability of the credential files is what matters for our usage, so access() is more appropriate than stat(). Reviewed-by: Marc-André Lureau Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Daniel P. Berrangé --- diff --git a/crypto/tlscreds.c b/crypto/tlscreds.c index 9e59594d67..208a7e6d8f 100644 --- a/crypto/tlscreds.c +++ b/crypto/tlscreds.c @@ -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 {