]> git.openfabrics.org - ~shefty/ibacm.git/commitdiff
ibacm/acme: Eliminate segfault when SLID/SGID not given
authorSean Hefty <sean.hefty@intel.com>
Thu, 31 May 2012 23:48:32 +0000 (16:48 -0700)
committerSean Hefty <sean.hefty@intel.com>
Thu, 31 May 2012 23:48:32 +0000 (16:48 -0700)
Problem and cause reported by Hal Rosenstock <hal@mellanox.com>

Signed-off-by: Sean Hefty <sean.hefty@intel.com>
Tested-by: Hal Rosenstock <hal@mellanox.com>
src/acme.c

index e6ae188ffffdee12857db6a8ef6bff358ae62109..0e1d4edc1cfa045f4602bfa4aed8e24318643247 100644 (file)
@@ -495,7 +495,8 @@ static int resolve_lid(struct ibv_path_record *path)
 {
        int ret;
 
-       path->slid = htons((uint16_t) atoi(src_addr));
+       if (src_addr)
+               path->slid = htons((uint16_t) atoi(src_addr));
        path->dlid = htons((uint16_t) atoi(dest_addr));
        path->reversible_numpath = IBV_PATH_RECORD_REVERSIBLE | 1;
 
@@ -510,10 +511,13 @@ static int resolve_gid(struct ibv_path_record *path)
 {
        int ret;
 
-       ret = inet_pton(AF_INET6, src_addr, &path->sgid);
-       if (ret <= 0) {
-               printf("inet_pton error on source address (%s): 0x%x\n", src_addr, ret);
-               return ret ? ret : -1;
+       if (src_addr) {
+               ret = inet_pton(AF_INET6, src_addr, &path->sgid);
+               if (ret <= 0) {
+                       printf("inet_pton error on source address (%s): 0x%x\n",
+                              src_addr, ret);
+                       return ret ? ret : -1;
+               }
        }
 
        ret = inet_pton(AF_INET6, dest_addr, &path->dgid);