aboutsummaryrefslogtreecommitdiff
path: root/lib/vtls
diff options
context:
space:
mode:
Diffstat (limited to 'lib/vtls')
-rw-r--r--lib/vtls/vtls.c37
1 files changed, 21 insertions, 16 deletions
diff --git a/lib/vtls/vtls.c b/lib/vtls/vtls.c
index c493b1516..9d194f8ba 100644
--- a/lib/vtls/vtls.c
+++ b/lib/vtls/vtls.c
@@ -1236,7 +1236,7 @@ static size_t Curl_multissl_version(char *buffer, size_t size)
{
static const struct Curl_ssl *selected;
static char backends[200];
- static size_t total;
+ static size_t backends_len;
const struct Curl_ssl *current;
current = Curl_ssl == &Curl_ssl_multi ? available_backends[0] : Curl_ssl;
@@ -1248,27 +1248,32 @@ static size_t Curl_multissl_version(char *buffer, size_t size)
selected = current;
- for(i = 0; available_backends[i] && p < (end - 4); i++) {
- if(i)
- *(p++) = ' ';
- if(selected != available_backends[i])
- *(p++) = '(';
- p += available_backends[i]->version(p, end - p - 2);
- if(selected != available_backends[i])
- *(p++) = ')';
+ backends[0] = '\0';
+
+ for(i = 0; available_backends[i]; ++i) {
+ char vb[200];
+ bool paren = (selected != available_backends[i]);
+
+ if(available_backends[i]->version(vb, sizeof(vb))) {
+ p += msnprintf(p, end - p, "%s%s%s%s", (p != backends ? " " : ""),
+ (paren ? "(" : ""), vb, (paren ? ")" : ""));
+ }
}
- *p = '\0';
- total = p - backends;
+
+ backends_len = p - backends;
}
- if(size > total)
- memcpy(buffer, backends, total + 1);
- else {
- memcpy(buffer, backends, size - 1);
+ if(!size)
+ return 0;
+
+ if(size <= backends_len) {
+ strncpy(buffer, backends, size - 1);
buffer[size - 1] = '\0';
+ return size - 1;
}
- return CURLMIN(size - 1, total);
+ strcpy(buffer, backends);
+ return backends_len;
}
static int multissl_init(const struct Curl_ssl *backend)