]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
mbedtls: cut off trailing newlines from debug logs
authorDaniel Stenberg <daniel@haxx.se>
Fri, 12 Apr 2024 08:57:02 +0000 (10:57 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 12 Apr 2024 16:27:45 +0000 (18:27 +0200)
To avoid double newlines in the output.

Reported-by: Gisle Vanem
Fixes #13321
Closes #13356

lib/vtls/mbedtls.c

index 4967beac369c01dab4704df56811bb133b72ccec..a70a6b6fe0c7d840de74dd826bfc54ea95efa8e1 100644 (file)
@@ -163,15 +163,18 @@ static int entropy_func_mutex(void *data, unsigned char *output, size_t len)
 static void mbed_debug(void *context, int level, const char *f_name,
                        int line_nb, const char *line)
 {
-  struct Curl_easy *data = NULL;
-
-  if(!context)
-    return;
-
-  data = (struct Curl_easy *)context;
-
-  infof(data, "%s", line);
+  struct Curl_easy *data = (struct Curl_easy *)context;
   (void) level;
+  (void) line_nb;
+  (void) f_name;
+
+  if(data) {
+    size_t len = strlen(line);
+    if(len && (line[len - 1] == '\n'))
+      /* discount any trailing newline */
+      len--;
+    infof(data, "%.*s", (int)len, line);
+  }
 }
 #endif