Craig Fields (now part of Scrawl!) found this bug.  I'm submitting it on
his (and Scrawl's) behalf.  A source fix for the bug and a workaround
are also provided.

Sanjay
Scrawl, LLC

---------------

Subject: Palm DNS library bug description

When using NetLibGetHostByName to look up a hostname which returns
more than three IP addresses ("americaonline.aol.com" for example),
the "addressList" array of NetHostInfoBufType is overrun, and the NULL
termination of that array falls into the "address" array. Thus the
first IP address returned becomes 0.0.0.0. "addressList" should have
been declared to be length netDNSMaxAddresses+1, as aliasList was.

The workaround I am using is to test NetHostInfoPtr->addrListP[0] == 0
and skip it if so.

===
Relevant declaration from NetMgr.h:

#define netDNSMaxAddresses      4       // max # of addresses for a host

// "Buffer" passed to call as a place to store the results
typedef struct {
  NetHostInfoType hostInfo;     // high level results of call are here

  // The following fields contain the variable length data that 
  //  hostInfo points to
  Char          name[netDNSMaxDomainName+1];    // hostInfo->name

  CharPtr       aliasList[netDNSMaxAliases+1];  // +1 for 0 termination.
  Char          aliases[netDNSMaxAliases][netDNSMaxDomainName+1];

  NetIPAddr*    addressList[netDNSMaxAddresses];
  NetIPAddr     address[netDNSMaxAddresses];
} NetHostInfoBufType, *NetHostInfoBufPtr;

Reply via email to