]> git.openfabrics.org - ~shefty/librdmacm.git/commitdiff
librdmacm: do not pass uninitialized ai_hints into getaddrinfo
authorSean Hefty <sean.hefty@intel.com>
Thu, 19 Aug 2010 22:00:29 +0000 (15:00 -0700)
committerSean Hefty <sean.hefty@intel.com>
Thu, 19 Aug 2010 22:00:29 +0000 (15:00 -0700)
If rdma_getaddrinfo is called with hints set to NULL, then an
uninitialized ai_hints structure will be passed into getaddrinfo.

Signed-off-by: Sean Hefty <sean.hefty@intel.com>
src/addrinfo.c [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index c8d9f0c..7c7056f
@@ -136,17 +136,21 @@ int rdma_getaddrinfo(char *node, char *service,
 {
        struct rdma_addrinfo *rai;
        struct addrinfo ai_hints;
-       struct addrinfo *ai;
+       struct addrinfo *ai, *aih;
        int ret;
 
        ret = ucma_init();
        if (ret)
                return ret;
 
-       if (hints)
+       if (hints) {
                ucma_convert_to_ai(&ai_hints, hints);
+               aih = &ai_hints;
+       } else {
+               aih = NULL;
+       }
 
-       ret = getaddrinfo(node, service, &ai_hints, &ai);
+       ret = getaddrinfo(node, service, aih, &ai);
        if (ret)
                return ret;