[krbdev.mit.edu #3172] AIX 4.x ns_ninit corrupts memory due to incompatibility with resolv.h

donn@u.washington.edu via RT rt-comment at krbdev.mit.edu
Wed Aug 31 18:50:21 EDT 2005


On Aug 31, 2005, at 3:12 PM, Tom Yu via RT wrote:

> Thanks for the report.  If you have access to both AIX 4.x and AIX 5.x
> systems, could you tell us whether res_ndestroy() is present in the
> headers, and whether it can be linked?  I'm attempting to update our
> strategy for determining whether to use res_ninit().

Nope, neither 4.3 nor 5.2 declare res_ndestroy, in resolv.h
or anything included by it.

I don't suppose this would actually be convenient for your
purposes, but since this is a very specific exception to your
general wish to use res_ninit() ... here's the minimum direct
test for the specific condition.

     Donn Cave, donn at u.washington.edu
------------------------------------
#include <string.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <arpa/nameser.h>
#include <resolv.h>
#include <netdb.h>

int
main(int argc, char **argv)
{
         struct __res_state statbuf[3];
         unsigned int *ph;

         ph = (unsigned int *) statbuf;
         ph[(sizeof(struct __res_state) + sizeof(*ph) - 1)/sizeof(*ph)]
                 = 0x41322314;
         if (res_ninit(statbuf) < 0) {
                 perror("res_ninit");
                 return 0;
         }
         return ph[(sizeof(struct __res_state) + sizeof(*ph) - 1)/ 
sizeof(*ph)]
                 != 0x41322314;
}




More information about the krb5-bugs mailing list