lib: reduce use of strncpy

- bearssl: select cipher without buffer copies
- http_aws_sigv4: avoid strncpy, require exact timestamp length
- http_aws_sigv4: use memcpy isntead of strncpy
- openssl: avoid strncpy calls
- schannel: check for 1.3 algos without buffer copies
- strerror: avoid strncpy calls
- telnet: avoid strncpy, return error on too long inputs
- vtls: avoid strncpy in multissl_version()

Closes #12499
This commit is contained in:
Daniel Stenberg 2023-12-11 16:15:57 +01:00
parent 9efdefe6b1
commit ff74cef5d4
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
7 changed files with 101 additions and 98 deletions

View file

@ -826,23 +826,27 @@ static CURLcode check_telnet_options(struct Curl_easy *data)
case 5:
/* Terminal type */
if(strncasecompare(option, "TTYPE", 5)) {
strncpy(tn->subopt_ttype, arg, 31);
tn->subopt_ttype[31] = 0; /* String termination */
tn->us_preferred[CURL_TELOPT_TTYPE] = CURL_YES;
size_t l = strlen(arg);
if(l < sizeof(tn->subopt_ttype)) {
strcpy(tn->subopt_ttype, arg);
tn->us_preferred[CURL_TELOPT_TTYPE] = CURL_YES;
break;
}
}
else
result = CURLE_UNKNOWN_OPTION;
result = CURLE_UNKNOWN_OPTION;
break;
case 8:
/* Display variable */
if(strncasecompare(option, "XDISPLOC", 8)) {
strncpy(tn->subopt_xdisploc, arg, 127);
tn->subopt_xdisploc[127] = 0; /* String termination */
tn->us_preferred[CURL_TELOPT_XDISPLOC] = CURL_YES;
size_t l = strlen(arg);
if(l < sizeof(tn->subopt_xdisploc)) {
strcpy(tn->subopt_xdisploc, arg);
tn->us_preferred[CURL_TELOPT_XDISPLOC] = CURL_YES;
break;
}
}
else
result = CURLE_UNKNOWN_OPTION;
result = CURLE_UNKNOWN_OPTION;
break;
case 7: