tool: Fixed incorrect return code if password prompting runs out of memory
Due to the changes in commit 3c929ff9f6
and lack of subsequent
updates, curl could return a CURLE_FTP_ACCEPT_FAILED error if
checkpasswd() ran out of memory in versions 7.33.0 and 7.34.0.
Updated the function declaration and return code to return
CURLE_OUT_OF_MEMORY and CURLE_OK where appropriate.
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
* | (__| |_| | _ <| |___
|
* | (__| |_| | _ <| |___
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
@@ -365,14 +365,14 @@ ParameterError str2offset(curl_off_t *val, const char *str)
|
|||||||
return PARAM_BAD_NUMERIC;
|
return PARAM_BAD_NUMERIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
ParameterError checkpasswd(const char *kind, /* for what purpose */
|
CURLcode checkpasswd(const char *kind, /* for what purpose */
|
||||||
char **userpwd) /* pointer to allocated string */
|
char **userpwd) /* pointer to allocated string */
|
||||||
{
|
{
|
||||||
char *psep;
|
char *psep;
|
||||||
char *osep;
|
char *osep;
|
||||||
|
|
||||||
if(!*userpwd)
|
if(!*userpwd)
|
||||||
return PARAM_OK;
|
return CURLE_OK;
|
||||||
|
|
||||||
/* Attempt to find the password separator */
|
/* Attempt to find the password separator */
|
||||||
psep = strchr(*userpwd, ':');
|
psep = strchr(*userpwd, ':');
|
||||||
@@ -408,14 +408,15 @@ ParameterError checkpasswd(const char *kind, /* for what purpose */
|
|||||||
passwdlen + 1 + /* an extra for the colon */
|
passwdlen + 1 + /* an extra for the colon */
|
||||||
userlen + 1); /* an extra for the zero */
|
userlen + 1); /* an extra for the zero */
|
||||||
if(!passptr)
|
if(!passptr)
|
||||||
return PARAM_NO_MEM;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
/* append the password separated with a colon */
|
/* append the password separated with a colon */
|
||||||
passptr[userlen] = ':';
|
passptr[userlen] = ':';
|
||||||
memcpy(&passptr[userlen+1], passwd, passwdlen+1);
|
memcpy(&passptr[userlen+1], passwd, passwdlen+1);
|
||||||
*userpwd = passptr;
|
*userpwd = passptr;
|
||||||
}
|
}
|
||||||
return PARAM_OK;
|
|
||||||
|
return CURLE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ParameterError add2list(struct curl_slist **list, const char *ptr)
|
ParameterError add2list(struct curl_slist **list, const char *ptr)
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
* | (__| |_| | _ <| |___
|
* | (__| |_| | _ <| |___
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
@@ -40,7 +40,7 @@ long proto2num(struct Configurable *config, long *val, const char *str);
|
|||||||
|
|
||||||
ParameterError str2offset(curl_off_t *val, const char *str);
|
ParameterError str2offset(curl_off_t *val, const char *str);
|
||||||
|
|
||||||
ParameterError checkpasswd(const char *kind, char **userpwd);
|
CURLcode checkpasswd(const char *kind, char **userpwd);
|
||||||
|
|
||||||
ParameterError add2list(struct curl_slist **list, const char *ptr);
|
ParameterError add2list(struct curl_slist **list, const char *ptr);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user