You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by "rucong zhao (JIRA)" <xe...@xml.apache.org> on 2009/05/26 08:46:45 UTC
[jira] Created: (XERCESC-1871) getaddrinfo() hits Segmentation
fault on FreeBSD when accessing remote data.
getaddrinfo() hits Segmentation fault on FreeBSD when accessing remote data.
----------------------------------------------------------------------------
Key: XERCESC-1871
URL: https://issues.apache.org/jira/browse/XERCESC-1871
Project: Xerces-C++
Issue Type: Bug
Components: Utilities
Environment: FreeBSD 6.2
Reporter: rucong zhao
Priority: Minor
Hi,
When accessing remote data, my program hits Segmentation fault. I've debug the issue and make sure that the cause is using "if (n<0)" to judge the getaddrinfo errors. In fact we should use "if (n!=0)" according to getaddrinfo() standard.
In the file: xercesc/src/xercesc/util/NetAccessors/Socket/UnixHTTPURLInputStream.cpp, line 127:
int n = getaddrinfo(hostNameAsCharStar,portBuffer.getRawBuffer(),&hints, &res);
if(n<0)
{
hints.ai_flags = AI_NUMERICHOST;
n = getaddrinfo(hostNameAsCharStar,portBuffer.getRawBuffer(),&hints, &res);
if(n<0)
ThrowXMLwithMemMgr1(NetAccessorException, XMLExcepts::NetAcc_TargetResolution, hostName, memoryManager);
}
http://linux.die.net/man/3/getaddrinfo point out that "getaddrinfo(3) returns 0 if it succeeds, or one of the following non-zero error codes". So the error code is not negative in all platform.
I've wrote a test program and run in both Linux and FreeBSD. The result show that the error codes on FreeBSD are positive number:
Linux:
error in getaddrinfo: Name or service not known
error code: -2
FreeBSD:
error in getaddrinfo: hostname nor servname provided, or not known
error code: 8
So the fix should be changing upon two "if(n<0)" into "if(n!=0)". The fix works on my machine.
Thanks,
Rucong
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org
[jira] Closed: (XERCESC-1871) getaddrinfo() hits Segmentation fault
on FreeBSD when accessing remote data.
Posted by "Boris Kolpackov (JIRA)" <xe...@xml.apache.org>.
[ https://issues.apache.org/jira/browse/XERCESC-1871?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Boris Kolpackov closed XERCESC-1871.
------------------------------------
Resolution: Fixed
Fix Version/s: 3.1.0
3.0.2
Assignee: Boris Kolpackov
Fix is in SVN, thanks.
> getaddrinfo() hits Segmentation fault on FreeBSD when accessing remote data.
> ----------------------------------------------------------------------------
>
> Key: XERCESC-1871
> URL: https://issues.apache.org/jira/browse/XERCESC-1871
> Project: Xerces-C++
> Issue Type: Bug
> Components: Utilities
> Environment: FreeBSD 6.2
> Reporter: rucong zhao
> Assignee: Boris Kolpackov
> Priority: Minor
> Fix For: 3.0.2, 3.1.0
>
>
> Hi,
> When accessing remote data, my program hits Segmentation fault. I've debug the issue and make sure that the cause is using "if (n<0)" to judge the getaddrinfo errors. In fact we should use "if (n!=0)" according to getaddrinfo() standard.
> In the file: xercesc/src/xercesc/util/NetAccessors/Socket/UnixHTTPURLInputStream.cpp, line 127:
> int n = getaddrinfo(hostNameAsCharStar,portBuffer.getRawBuffer(),&hints, &res);
> if(n<0)
> {
> hints.ai_flags = AI_NUMERICHOST;
> n = getaddrinfo(hostNameAsCharStar,portBuffer.getRawBuffer(),&hints, &res);
> if(n<0)
> ThrowXMLwithMemMgr1(NetAccessorException, XMLExcepts::NetAcc_TargetResolution, hostName, memoryManager);
> }
> http://linux.die.net/man/3/getaddrinfo point out that "getaddrinfo(3) returns 0 if it succeeds, or one of the following non-zero error codes". So the error code is not negative in all platform.
> I've wrote a test program and run in both Linux and FreeBSD. The result show that the error codes on FreeBSD are positive number:
> Linux:
> error in getaddrinfo: Name or service not known
> error code: -2
> FreeBSD:
> error in getaddrinfo: hostname nor servname provided, or not known
> error code: 8
> So the fix should be changing upon two "if(n<0)" into "if(n!=0)". The fix works on my machine.
> Thanks,
> Rucong
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org