mirror of
https://github.com/moparisthebest/curl
synced 2024-11-16 22:45:03 -05:00
parent
70a3b003d9
commit
a167949848
@ -413,6 +413,7 @@ ParameterError str2offset(curl_off_t *val, const char *str)
|
|||||||
return PARAM_BAD_NUMERIC;
|
return PARAM_BAD_NUMERIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define MAX_USERPWDLENGTH (100*1024)
|
||||||
static CURLcode checkpasswd(const char *kind, /* for what purpose */
|
static CURLcode checkpasswd(const char *kind, /* for what purpose */
|
||||||
const size_t i, /* operation index */
|
const size_t i, /* operation index */
|
||||||
const bool last, /* TRUE if last operation */
|
const bool last, /* TRUE if last operation */
|
||||||
@ -432,12 +433,11 @@ static CURLcode checkpasswd(const char *kind, /* for what purpose */
|
|||||||
|
|
||||||
if(!psep && **userpwd != ';') {
|
if(!psep && **userpwd != ';') {
|
||||||
/* no password present, prompt for one */
|
/* no password present, prompt for one */
|
||||||
char passwd[256] = "";
|
char passwd[2048] = "";
|
||||||
char prompt[256];
|
char prompt[256];
|
||||||
size_t passwdlen;
|
struct curlx_dynbuf dyn;
|
||||||
size_t userlen = strlen(*userpwd);
|
|
||||||
char *passptr;
|
|
||||||
|
|
||||||
|
curlx_dyn_init(&dyn, MAX_USERPWDLENGTH);
|
||||||
if(osep)
|
if(osep)
|
||||||
*osep = '\0';
|
*osep = '\0';
|
||||||
|
|
||||||
@ -453,22 +453,15 @@ static CURLcode checkpasswd(const char *kind, /* for what purpose */
|
|||||||
|
|
||||||
/* get password */
|
/* get password */
|
||||||
getpass_r(prompt, passwd, sizeof(passwd));
|
getpass_r(prompt, passwd, sizeof(passwd));
|
||||||
passwdlen = strlen(passwd);
|
|
||||||
|
|
||||||
if(osep)
|
if(osep)
|
||||||
*osep = ';';
|
*osep = ';';
|
||||||
|
|
||||||
/* extend the allocated memory area to fit the password too */
|
if(curlx_dyn_addf(&dyn, "%s:%s", *userpwd, passwd))
|
||||||
passptr = realloc(*userpwd,
|
|
||||||
passwdlen + 1 + /* an extra for the colon */
|
|
||||||
userlen + 1); /* an extra for the zero */
|
|
||||||
if(!passptr)
|
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
/* append the password separated with a colon */
|
/* return the new string */
|
||||||
passptr[userlen] = ':';
|
free(*userpwd);
|
||||||
memcpy(&passptr[userlen + 1], passwd, passwdlen + 1);
|
*userpwd = curlx_dyn_ptr(&dyn);
|
||||||
*userpwd = passptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
|
Loading…
Reference in New Issue
Block a user