[utils,proxy] refactor proxy_parse_uri
* eliminate deadstore warnings * fix missing input checks
This commit is contained in:
parent
8a0194c105
commit
a1a8846ad2
@ -22,12 +22,20 @@
|
||||
#define FREERDP_PROXY_UTILS_H
|
||||
|
||||
#include <freerdp/api.h>
|
||||
#include <freerdp/settings.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/** @brief parse a proxy environment variable string and populate settings from it
|
||||
*
|
||||
* @param settings the settings to populate, must not be \b NULL
|
||||
* @param uri_in the proxy string to parse, must not be \b NULL
|
||||
*
|
||||
* @return \b TRUE if parsed successfully
|
||||
*/
|
||||
FREERDP_API BOOL proxy_parse_uri(rdpSettings* settings, const char* uri_in);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include <openssl/err.h>
|
||||
|
||||
@ -329,14 +330,16 @@ BOOL proxy_parse_uri(rdpSettings* settings, const char* uri_in)
|
||||
BOOL rc = FALSE;
|
||||
const char* protocol = "";
|
||||
UINT16 port = 0;
|
||||
char* p = NULL;
|
||||
char* atPtr = NULL;
|
||||
|
||||
if (!settings || !uri_in)
|
||||
return FALSE;
|
||||
|
||||
char* uri_copy = _strdup(uri_in);
|
||||
char* uri = uri_copy;
|
||||
if (!uri)
|
||||
goto fail;
|
||||
|
||||
p = strstr(uri, "://");
|
||||
char* p = strstr(uri, "://");
|
||||
|
||||
if (p)
|
||||
{
|
||||
@ -376,7 +379,7 @@ BOOL proxy_parse_uri(rdpSettings* settings, const char* uri_in)
|
||||
}
|
||||
|
||||
/* uri is now [user:password@]hostname:port */
|
||||
atPtr = strrchr(uri, '@');
|
||||
char* atPtr = strrchr(uri, '@');
|
||||
|
||||
if (atPtr)
|
||||
{
|
||||
@ -480,6 +483,9 @@ BOOL proxy_parse_uri(rdpSettings* settings, const char* uri_in)
|
||||
rc = TRUE;
|
||||
|
||||
fail:
|
||||
if (!rc)
|
||||
WLog_WARN(TAG, "Failed to parse proxy configuration: %s://%s:%" PRIu16, protocol, uri,
|
||||
port);
|
||||
free(uri_copy);
|
||||
return rc;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user