The Samba-Bugzilla – Attachment 5060 Details for
Bug 6970
getifaddrs() issues on AIX
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for bug 6970 (II)
diff2.patch (text/plain), 3.61 KB, created by
Miguel Sanders (mail account dead)
on 2009-12-06 14:17:35 UTC
(
hide
)
Description:
Patch for bug 6970 (II)
Filename:
MIME Type:
Creator:
Miguel Sanders (mail account dead)
Created:
2009-12-06 14:17:35 UTC
Size:
3.61 KB
patch
obsolete
>--- getifaddrsOLD.c 2009-12-06 12:27:36.000000000 +0100 >+++ getifaddrs.c 2009-12-06 19:44:54.000000000 +0100 >@@ -249,96 +249,98 @@ > #define _FOUND_IFACE_ANY > #endif /* HAVE_IFACE_IFREQ */ > #ifdef HAVE_IFACE_AIX > > /**************************************************************************** >-this one is for AIX (tested on 4.2) >+this one is for AIX (tested on 5.3 / 6.1) > ****************************************************************************/ > int rep_getifaddrs(struct ifaddrs **ifap) > { >- char buff[8192]; >- int fd, i; >+ int fd, size; > struct ifconf ifc; >- struct ifreq *ifr=NULL; >+ struct ifreq *ifr = NULL; > struct ifaddrs *curif; > struct ifaddrs *lastif = NULL; >+ void *current, *end; > > *ifap = NULL; > > if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) { > return -1; > } > >- ifc.ifc_len = sizeof(buff); >- ifc.ifc_buf = buff; >+ if (ioctl(fd, SIOCGSIZIFCONF, &size) != 0) { >+ return -1; >+ } >+ >+ ifc.ifc_len = size; >+ ifc.ifc_req = (struct ifreq *)malloc(size); > > if (ioctl(fd, SIOCGIFCONF, &ifc) != 0) { > close(fd); > return -1; > } > > ifr = ifc.ifc_req; >+ current = (void *)ifr; >+ end = (void *)ifr + ifc.ifc_len; > >- /* Loop through interfaces */ >- i = ifc.ifc_len; >- >- while (i > 0) { >- uint_t inc; >+ while (current < end) { >+ ifr = (struct ifreq *)current; >+ struct sockaddr *sa = (struct sockaddr *)&(ifr->ifr_addr); >+ sa_family_t fam = ((struct sockaddr_in *)sa)->sin_family; >+ >+ if(fam == AF_INET || fam == AF_INET6) { >+ curif = calloc(1, sizeof(struct ifaddrs)); >+ if (lastif == NULL) { >+ *ifap = curif; >+ } else { >+ lastif->ifa_next = curif; >+ } >+ >+ curif->ifa_name = strdup(ifr->ifr_name); >+ curif->ifa_addr = sockaddr_dup(&ifr->ifr_addr); >+ curif->ifa_dstaddr = NULL; >+ curif->ifa_data = NULL; >+ curif->ifa_netmask = NULL; >+ curif->ifa_next = NULL; >+ >+ if (ioctl(fd, SIOCGIFFLAGS, ifr) != 0) { >+ freeaddrinfo(*ifap); >+ return -1; >+ } >+ >+ curif->ifa_flags = ifr->ifr_flags; >+ >+ if (ioctl(fd, SIOCGIFNETMASK, ifr) != 0) { >+ freeaddrinfo(*ifap); >+ return -1; >+ } > >- inc = ifr->ifr_addr.sa_len; >+ curif->ifa_netmask = sockaddr_dup(&ifr->ifr_addr); > >- if (ioctl(fd, SIOCGIFADDR, ifr) != 0) { >- freeaddrinfo(*ifap); >- return -1; >+ lastif = curif; > } > >- curif = calloc(1, sizeof(struct ifaddrs)); >- if (lastif == NULL) { >- *ifap = curif; >- } else { >- lastif->ifa_next = curif; >- } >- >- curif->ifa_name = strdup(ifr->ifr_name); >- curif->ifa_addr = sockaddr_dup(&ifr->ifr_addr); >- curif->ifa_dstaddr = NULL; >- curif->ifa_data = NULL; >- curif->ifa_netmask = NULL; >- curif->ifa_next = NULL; >- >- if (ioctl(fd, SIOCGIFFLAGS, ifr) != 0) { >- freeaddrinfo(*ifap); >- return -1; >- } >- >- curif->ifa_flags = ifr->ifr_flags; >- >- if (ioctl(fd, SIOCGIFNETMASK, ifr) != 0) { >- freeaddrinfo(*ifap); >- return -1; >- } >- >- curif->ifa_netmask = sockaddr_dup(&ifr->ifr_addr); >- >- lastif = curif; >- >- next: > /* > * Patch from Archie Cobbs (archie@whistle.com). The > * addresses in the SIOCGIFCONF interface list have a > * minimum size. Usually this doesn't matter, but if > * your machine has tunnel interfaces, etc. that have >- * a zero length "link address", this does matter. */ >+ * a zero length "link address", this does matter. >+ */ > >- if (inc < sizeof(ifr->ifr_addr)) >- inc = sizeof(ifr->ifr_addr); >- inc += IFNAMSIZ; >+ int inc = ifr->ifr_addr.sa_len; >+ if (inc < sizeof(ifr->ifr_addr)) { >+ inc = sizeof(ifr->ifr_addr); >+ } >+ inc += IFNAMSIZ; > >- ifr = (struct ifreq*) (((char*) ifr) + inc); >- i -= inc; >+ current += inc; > } > >+ free(ifc.ifc_req); > close(fd); > return 0; > } > > #define _FOUND_IFACE_ANY
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 6970
:
5057
|
5060
|
8357
|
13270
|
13811
|
13814
|
13815
|
14082