getifaddrs.patch: use HAVE_SA_LEN macro

This commit is contained in:
Jiri Popelka 2012-05-25 18:15:27 +02:00
parent 8629ede7d2
commit e95bff28fe
2 changed files with 13 additions and 14 deletions

View File

@ -1,6 +1,6 @@
diff -up dhcp-4.2.3-P2/common/discover.c.getifaddrs dhcp-4.2.3-P2/common/discover.c
--- dhcp-4.2.3-P2/common/discover.c.getifaddrs 2012-03-23 18:15:12.710606929 +0100
+++ dhcp-4.2.3-P2/common/discover.c 2012-03-23 20:03:41.238239134 +0100
diff -up dhcp-4.2.4rc2/common/discover.c.getifaddrs dhcp-4.2.4rc2/common/discover.c
--- dhcp-4.2.4rc2/common/discover.c.getifaddrs 2012-05-25 18:05:29.592024035 +0200
+++ dhcp-4.2.4rc2/common/discover.c 2012-05-25 18:12:05.254266023 +0200
@@ -379,394 +379,13 @@ end_iface_scan(struct iface_conf_list *i
ifaces->sock = -1;
}
@ -406,7 +406,7 @@ diff -up dhcp-4.2.3-P2/common/discover.c.getifaddrs dhcp-4.2.3-P2/common/discove
if (ifaces->next == NULL) {
*err = 0;
return 0;
@@ -825,8 +446,24 @@ next_iface(struct iface_info *info, int
@@ -825,8 +446,20 @@ next_iface(struct iface_info *info, int
return 0;
}
strcpy(info->name, ifaces->next->ifa_name);
@ -414,19 +414,15 @@ diff -up dhcp-4.2.3-P2/common/discover.c.getifaddrs dhcp-4.2.3-P2/common/discove
- ifaces->next->ifa_addr->sa_len);
+
+ memset(&info->addr, 0 , sizeof(info->addr));
+ /*
+ * getifaddrs() can on Linux with some interfaces like PPP or TEQL
+ * result in a record with no address (ifa_addr).
+ */
+
+ if (ifaces->next->ifa_addr != NULL) {
+/* Linux lacks the sa_len member in struct sockaddr. */
+#if defined(__linux)
+#ifdef HAVE_SA_LEN
+ sa_len = ifaces->next->ifa_addr->sa_len;
+#else
+ if (ifaces->next->ifa_addr->sa_family == AF_INET)
+ sa_len = sizeof(struct sockaddr_in);
+ else if (ifaces->next->ifa_addr->sa_family == AF_INET6)
+ sa_len = sizeof(struct sockaddr_in6);
+#else
+ sa_len = ifaces->next->ifa_addr->sa_len;
+#endif
+ memcpy(&info->addr, ifaces->next->ifa_addr, sa_len);
+ }

View File

@ -19,7 +19,7 @@
Summary: Dynamic host configuration protocol software
Name: dhcp
Version: 4.2.4
Release: 0.6.%{prever}%{?dist}
Release: 0.7.%{prever}%{?dist}
# NEVER CHANGE THE EPOCH on this package. The previous maintainer (prior to
# dcantrell maintaining the package) made incorrect use of the epoch and
# that's why it is at 12 now. It should have never been used, but it was.
@ -69,7 +69,7 @@ Patch35: dhcp-4.2.2-gpxe-cid.patch
Patch36: dhcp-4.2.4-systemtap.patch
Patch37: dhcp-4.2.3-dhclient-decline-onetry.patch
Patch38: dhcp-4.2.3-P2-log_perror.patch
Patch39: dhcp-4.2.3-P2-getifaddrs.patch
Patch39: dhcp-4.2.4-getifaddrs.patch
Patch40: dhcp-4.2.4-send_release.patch
Patch41: dhcp-4.2.3-P2-rfc5970-dhcpv6-options-for-network-boot.patch
@ -564,6 +564,9 @@ fi
%changelog
* Fri May 25 2012 Jiri Popelka <jpopelka@redhat.com> - 12:4.2.4-0.7.rc2
- getifaddrs.patch: use HAVE_SA_LEN macro
* Wed May 23 2012 Jiri Popelka <jpopelka@redhat.com> - 12:4.2.4-0.6.rc2
- 4.2.4rc2