Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 26 additions & 6 deletions source/util_api/ansc/AnscStringUtil/ansc_string_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -498,9 +498,29 @@ BOOL is_ValidIpAddressv6_port(PUCHAR pString)
return FALSE;
char *hostcpy = strdup((const char*)pString);
char *hostdup = strdup((const char*)pString);
if ((!hostcpy) || (!hostdup))
{
free(hostcpy);
free(hostdup);
return FALSE;
}
char* ipv6 = strtok(hostcpy,"]");
ipv6 = strtok(ipv6,"[");
/* ipv6 can be NULL if hostcpy did not contain a valid "[...]" token */
if (!ipv6)
{
free(hostcpy);
free(hostdup);
return FALSE;
}
char *port_ptr = strchr(hostdup,']');
/* port_ptr can be NULL if hostdup does not contain ']' */
if (!port_ptr)
{
free(hostcpy);
free(hostdup);
return FALSE;
}
if(port_ptr[1])
{
if((port_ptr[1]==':') && (isdigit(port_ptr[2])))
Expand All @@ -509,16 +529,16 @@ BOOL is_ValidIpAddressv6_port(PUCHAR pString)
port_ptr = strtok(NULL,":");
}
else
{
/* CID 252351, 252353 fix */
free(hostcpy);
free(hostdup);
{
/* CID 252351, 252353 fix */
free(hostcpy);
free(hostdup);
return FALSE;
}
}
}
if(is_Ipv6_address((PUCHAR)ipv6))
{
if(port_ptr[1])
if(port_ptr && port_ptr[1])
{
if(is_ValidPort((PUCHAR)port_ptr))
ret = TRUE;
Expand Down
Loading