Click here to Skip to main content
14,452,049 members
Rate this:
Please Sign up or sign in to vote.
Hi folks,
I'm writing a simple DNS application that query DNS server for different type of DNS type such as A, NS MX, SOA and so on. At the beginning, everything started well. Sent query for A type record of a domain and got the reply, same for NS and PTR. But when I got to the implementation of SOA type, I got stuck with the type of error that was given.

Compiling the project works fine but when tries to run it I got this error.

"Unhandled exception at 0x6a2b984f(msvcr90.dll)in MyProject.exe:
0xC0000005: Access violation reading location 0x77cf1939"


Using a debugger, I'm able to step through to find the line of code that’s coursing the problem. Below is the snippet part of the program:

if (m_type == "SOA" ){wType = DNS_TYPE_SOA;}

  case DNS_TYPE_SOA:
	cstrFullDetails.Format("   SOA %s  nameserv: %s", pDnsRecord->pName,
		DnsRecord->Data.SOA.pNamePrimaryServer);				
	cstrFullDetails.Format("admin: %s", pDnsRecord->Data.SOA.pNameAdministrator);				
	cstrFullDetails.Format("serial: %s", pDnsRecord->Data.SOA.dwSerialNo);				
	cstrFullDetails.Format("refresh: %s", pDnsRecord->Data.SOA.dwRefresh);				
	cstrFullDetails.Format("ttl: %s", pDnsRecord->Data.SOA.dwDefaultTtl);	
	cstrFullDetails.Format("expire: %s", pDnsRecord->Data.SOA.dwExpire);	
	cstrFullDetails.Format("retry: %s", pDnsRecord->Data.SOA.dwRetry);                
	break;

The error popped out when the program tries to execute the line of code underlined. I'm stuck and don’t know what next to do to resolve this. And just to point out, the file that it point to when click on break is “output.c” which is locked and embedded in Visual Studio 2008. Someone please help...

Thanks in advance.
Posted
Updated 11-Jun-10 23:48pm
v5
Comments
Moak 12-Jun-10 4:50am
   
Updated question and formatted code with <pre> tag, hope this helps.

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

Adeji wrote:
cstrFullDetails.Format("serial: %s", pDnsRecord->Data.SOA.dwSerialNo);


I may be wrong but it looks like you are trying to format a DWORD value as a string; the correct format control should be "%d". I think you are also overwriting your string with every cstrFullDetails.Format statement.
   
v2
Comments
Adeji 12-Jun-10 7:37am
   
Thanks Richard. that actually escaped my mind.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100