added more robust/accurate numeric ip address check

git-svn-id: svn://10.0.0.236/trunk@46851 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
valeski%netscape.com 1999-09-10 22:33:09 +00:00
parent d444fffb40
commit 8b70f352bf

View File

@ -533,7 +533,15 @@ nsresult nsSocketTransport::doResolveHost(void)
char dbbuf[PR_NETDB_BUF_SIZE];
PRHostEnt hostEnt;
if (nsString2::IsDigit(mHostName[0])) {
PRBool numeric = PR_TRUE;
for (char *hostCheck = mHostName; *hostCheck; hostCheck++) {
if (!nsString2::IsDigit(*hostCheck) && (*hostCheck != '.') ) {
numeric = PR_FALSE;
break;
}
}
if (numeric) {
PRNetAddr *netAddr = (PRNetAddr*)nsAllocator::Alloc(sizeof(PRNetAddr));
status = PR_StringToNetAddr(mHostName, netAddr);
if (PR_SUCCESS != status) {