This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

glibc: inet6_rth_init returned an abnormal address?


I did some test on inet6_rth_init, inet6_rth_init returnned a invalid address;
But I used inet6_rth_init_ww (the same implementation as inet6_rth_init) in my test code, It returnned a valid address.
Dose anyone konw why?

The test code:
	void *inet6_rth_init_ww(...)
	int main(void)
		char buf[10240];
		void *pbuf = NULL;
		void *pbuf1 = NULL;

		pbuf = inet6_rth_init((void *)buf, 10240, IPV6_RTHDR_TYPE_0, 0);
		pbuf1 = inet6_rth_init_ww((void *)buf, 10240, IPV6_RTHDR_TYPE_0, 0);
		printf("buf is 0x%lx, pbuf is 0x%lx, pbuf1 is 0x%lx\n", &buf, pbuf, pbuf1);

		return 0;

The test resultï
	buf is 0x7fff814a3fd0, pbuf is 0xffffffff814a3fd0, pbuf1 is 0x7fff814a3fd0
	buf is 0x7fff0eb7c850, pbuf is 0xeb7c850, pbuf1 is 0x7fff0eb7c850
The value of pbuf is a invalid addressïI traced inet6_rth_init, the return value of inet6_rth_init is ok (0x7fff....), why pbuf is invalid?

Disassemble code of main:
   0x0000000000400547 <+54>:	callq  0x40c7c0 <inet6_rth_init>
=> 0x000000000040054c <+59>:	cltq                        //until this step, registers value are ok
   0x000000000040054e <+61>:	mov    %rax,-0x10(%rbp)      //this step, the value of rax is 0xffffffff814a3fd0
=> 0x0000000000400568 <+87>:	callq  0x400474 <inet6_rth_init_ww>
   0x000000000040056d <+92>:	mov    %rax,-0x8(%rbp)  //this step, the value of rax is 0x7fff814a3fd0


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]