Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vtls: fix missing multissl version info #12599

Closed
wants to merge 1 commit into from

Conversation

jay
Copy link
Member

@jay jay commented Dec 27, 2023

  • Fix erroneous buffer copy logic from ff74cef.

Prior to this change the MultiSSL version info returned to the user was empty.

Closes #xxxx


before: libcurl/8.6.0-DEV nghttp2/1.52.0
after: libcurl/8.6.0-DEV OpenSSL/3.0.8 (Schannel) nghttp2/1.52.0

- Fix erroneous buffer copy logic from ff74cef.

Prior to this change the MultiSSL version info returned to the user
was empty.

Closes #xxxx
@jay
Copy link
Member Author

jay commented Dec 27, 2023

If truncation is preferred for inadequate buffers then another way to do this would be revert that file:

diff --git a/lib/vtls/vtls.c b/lib/vtls/vtls.c
index 256b8fa..dd68a06 100644
--- a/lib/vtls/vtls.c
+++ b/lib/vtls/vtls.c
@@ -1413,11 +1413,17 @@ static size_t multissl_version(char *buffer, size_t size)
     backends_len = p - backends;
   }
 
-  if(size && (size < backends_len))
-    strcpy(buffer, backends);
-  else
-    *buffer = 0; /* did not fit */
-  return 0;
+  if(!size)
+    return 0;
+
+  if(size <= backends_len) {
+    strncpy(buffer, backends, size - 1);
+    buffer[size - 1] = '\0';
+    return size - 1;
+  }
+
+  strcpy(buffer, backends);
+  return backends_len;
 }
 
 static int multissl_setup(const struct Curl_ssl *backend)

@jay jay closed this in e251e85 Dec 27, 2023
@jay jay deleted the fix_multissl_version branch December 27, 2023 22:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

None yet

2 participants