The code doesn't follow the structure layout. The layout is:
struct tt__IPAddress
{
enum tt__IPType Type; /* required element of type tt:IPType */
char *IPv4Address; /* optional element of type tt:IPv4Address */
char *IPv6Address; /* optional element of type tt:IPv6Address */
};
meaning: IPv4Address
is a char
pointer. yet this:
DNSInformation->DNSManual->IPv4Address = (char **)soap_malloc(soap, sizeof(char *));
is assigning a char **
cast to it. but the type is still char *
so this:
strncpy(*DNSInformation->DNSManual->IPv4Address, dns_string, LARGE_INFO_LENGTH-1);
is dereferencing said pointer to a single char
, which I can assure you is NOT compatible with a char *
on your platform (and likely any other for that matter).
There should be warnings running amok on this compilation at a minimum, and outright errors if your compiler has any brains at all. This looks like it was original intended to be this:
struct tt__IPAddress
{
enum tt__IPType Type;
char **IPv4Address; /* note ptr to ptr */
char **IPv6Address;
};
for having a dynamic pointer array, each pointer being dynamically allocated memory for a single IP address. if it were like this, it would make much more sense. That said, if you intend on only a single IPv4 address per structure then this should be changed:
DNSInformation->DNSManual = soap_malloc(soap, sizeof(struct tt__IPAddress)));
if (DNSInformation->DNSManual)
{
DNSInformation->DNSManual->IPv4Address = soap_malloc(soap, sizeof(char) * LARGE_INFO_LENGTH);
if (DNSInformation->DNSManual->IPv4Address)
{
strncpy(DNSInformation->DNSManual->IPv4Address, dns_string, LARGE_INFO_LENGTH-1);
DNSInformation->DNSManual->IPv4Address[LARGE_INFO_LENGTH-1] = 0;
}
}
Or something similar to that.