Replace strcpy with strncpy in get_hoststr

Replace strcpy with strncpy to avoid buffer overflow.
This commit is contained in:
Fabrice Fontaine
2012-03-08 17:23:46 +01:00
parent eb16f52b1a
commit 666bc7392b
2 changed files with 8 additions and 1 deletions

View File

@@ -169,7 +169,8 @@ static int get_hoststr(const char* url_str,
{
char *urlPath = alloca(strlen(url_str) + 1);
char *temp;
strcpy(urlPath, url_str);
memset(urlPath, 0, strlen(url_str) + 1);
strncpy(urlPath, url_str, strlen(url_str));
*hoststr = strstr(urlPath, "//");
if (*hoststr == NULL)
return UPNP_E_INVALID_URL;