[fix] - fix allocation of if list for osx
[deb_libnfs.git] / lib / libnfs-sync.c
index 82c09f38e36bb7f6761b33b52b78c98cbbe861c8..0a57c7b97e562c1844fd0b183271d1ff8fea2b7f 100644 (file)
@@ -18,6 +18,7 @@
  * High level api to nfs filesystems
  */
 
+#include "config.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -1226,7 +1227,7 @@ struct nfs_server_list *nfs_find_local_servers(void)
        ifc.ifc_buf = NULL;
        ifc.ifc_len = size;
 
-       while (ifc.ifc_len == size) {
+       while(ifc.ifc_len > (size - sizeof(struct ifreq))) {
                size *= 2;
 
                free(ifc.ifc_buf);      
@@ -1245,7 +1246,7 @@ struct nfs_server_list *nfs_find_local_servers(void)
                char bcdd[16];
 
                ifr = (struct ifreq *)ptr;
-#if HAVE_SOCKADDR_LEN
+#ifdef HAVE_SOCKADDR_LEN
                if (ifr->ifr_addr.sa_len > sizeof(struct sockaddr)) {
                        ptr += sizeof(ifr->ifr_name) + ifr->ifr_addr.sa_len;
                } else {