url: make parse_login_details use memdup0

Also make the user and password arguments mandatory, since all code
paths in libcurl used them anyway.

Adapted unit test case 1620 to the new rules.

Closes #13584
This commit is contained in:
Daniel Stenberg 2024-05-10 15:32:57 +02:00
parent fa9a564942
commit 0e37b42dc9
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
2 changed files with 42 additions and 61 deletions

View file

@ -46,6 +46,8 @@ UNITTEST_START
struct Curl_easy *empty;
const char *hostname = "hostname";
enum dupstring i;
char *userstr = NULL;
char *passwdstr = NULL;
bool async = FALSE;
bool protocol_connect = FALSE;
@ -73,10 +75,12 @@ UNITTEST_START
rc = Curl_init_do(empty, empty->conn);
fail_unless(rc == CURLE_OK, "Curl_init_do() failed");
rc = Curl_parse_login_details(
hostname, strlen(hostname), NULL, NULL, NULL);
rc = Curl_parse_login_details(hostname, strlen(hostname),
&userstr, &passwdstr, NULL);
fail_unless(rc == CURLE_OK,
"Curl_parse_login_details() failed");
free(userstr);
free(passwdstr);
Curl_freeset(empty);
for(i = (enum dupstring)0; i < STRING_LAST; i++) {