]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
lib/kx: Only report file open error if there is an error
authorAlistair Francis <alistair.francis@wdc.com>
Thu, 9 Oct 2025 04:57:08 +0000 (14:57 +1000)
committerDaiki Ueno <ueno@gnu.org>
Wed, 19 Nov 2025 11:47:00 +0000 (20:47 +0900)
Previously all attempts to open a `SSLKEYLOGFILE` would result in a
"unable to open keylog file" regardless of if the file was opened or
not. Instead let's only report the issue if the file fails to open.

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
lib/kx.c

index 36f95e852cb6a97b214c145f50d1db7b832ae441..0ab7ff78bb53a197c006c57878b8318d0f4b3bd2 100644 (file)
--- a/lib/kx.c
+++ b/lib/kx.c
@@ -138,8 +138,10 @@ static void keylog_once_init(void)
        keylogfile = secure_getenv("SSLKEYLOGFILE");
        if (keylogfile != NULL && *keylogfile != '\0') {
                keylog = fopen(keylogfile, "ae");
-               _gnutls_debug_log("unable to open keylog file %s\n",
-                                 keylogfile);
+               if (keylog == NULL)
+                       _gnutls_debug_log(
+                               "unable to open keylog file %s, error %d\n",
+                               keylogfile, errno);
        }
 }