]> git.ipfire.org Git - ipfire-3.x.git/blobdiff - dhcp/patches/0025-dhcp-getifaddrs.patch
dhcp: Update to 4.3.5b1
[ipfire-3.x.git] / dhcp / patches / 0025-dhcp-getifaddrs.patch
similarity index 89%
rename from dhcp/patches/dhcp-4.2.4-getifaddrs.patch
rename to dhcp/patches/0025-dhcp-getifaddrs.patch
index 330a1fc6882bb5aa4e6c1f93909f39fa721ad980..586c3b077e85817dec591f2617bd1f5a1f9cf6f5 100644 (file)
@@ -1,19 +1,7 @@
-From c09dd24a7d63988e0acef7d033bd3e088fc005c0 Mon Sep 17 00:00:00 2001
-From: Jiri Popelka <jpopelka@redhat.com>
-Date: Thu, 24 Jan 2013 12:39:50 +0100
-Subject: [PATCH] Linux interface discovery
-
-Use the same discovery code as for *BSD and OS X,
-i.e. the getifaddrs() function.
----
- common/discover.c | 398 +++---------------------------------------------------
- 1 file changed, 17 insertions(+), 381 deletions(-)
-
-diff --git a/common/discover.c b/common/discover.c
-index 1d84219..f2a8f6d 100644
---- a/common/discover.c
-+++ b/common/discover.c
-@@ -379,391 +379,13 @@ end_iface_scan(struct iface_conf_list *ifaces) {
+diff -up dhcp-4.3.5b1/common/discover.c.getifaddrs dhcp-4.3.5b1/common/discover.c
+--- dhcp-4.3.5b1/common/discover.c.getifaddrs  2016-09-12 17:10:39.585374741 +0200
++++ dhcp-4.3.5b1/common/discover.c     2016-09-12 17:15:56.160628636 +0200
+@@ -373,392 +373,13 @@ end_iface_scan(struct iface_conf_list *i
        ifaces->sock = -1;
  }
  
@@ -55,7 +43,7 @@ index 1d84219..f2a8f6d 100644
 - */
 -int 
 -begin_iface_scan(struct iface_conf_list *ifaces) {
--      char buf[256];
+-      char buf[IF_LINE_LENGTH];
 -      int len;
 -      int i;
 -
@@ -128,7 +116,7 @@ index 1d84219..f2a8f6d 100644
 - */
 -static int
 -next_iface4(struct iface_info *info, int *err, struct iface_conf_list *ifaces) {
--      char buf[256];
+-      char buf[IF_LINE_LENGTH];
 -      int len;
 -      char *p;
 -      char *name;
@@ -191,7 +179,7 @@ index 1d84219..f2a8f6d 100644
 -                              log_error("Interface name '%s' too long", name);
 -                              return 0;
 -                      }
--                      strcpy(info->name, name);
+-                      strncpy(info->name, name, sizeof(info->name) - 1);
 -
 -#ifdef ALIAS_NAMED_PERMUTED
 -                      /* interface aliases look like "eth0:1" or "wlan1:3" */
@@ -208,7 +196,7 @@ index 1d84219..f2a8f6d 100644
 -#endif
 -
 -              memset(&tmp, 0, sizeof(tmp));
--              strcpy(tmp.ifr_name, name);
+-              strncpy(tmp.ifr_name, name, sizeof(tmp.ifr_name) - 1);
 -              if (ioctl(ifaces->sock, SIOCGIFADDR, &tmp) < 0) {
 -                      if (errno == EADDRNOTAVAIL) {
 -                              continue;
@@ -221,7 +209,7 @@ index 1d84219..f2a8f6d 100644
 -              memcpy(&info->addr, &tmp.ifr_addr, sizeof(tmp.ifr_addr));
 -
 -              memset(&tmp, 0, sizeof(tmp));
--              strcpy(tmp.ifr_name, name);
+-              strncpy(tmp.ifr_name, name, sizeof(tmp.ifr_name) - 1);
 -              if (ioctl(ifaces->sock, SIOCGIFFLAGS, &tmp) < 0) {
 -                      log_error("Error getting interface flags for '%s'; %m", 
 -                              name);
@@ -252,7 +240,7 @@ index 1d84219..f2a8f6d 100644
 - */
 -static int
 -next_iface6(struct iface_info *info, int *err, struct iface_conf_list *ifaces) {
--      char buf[256];
+-      char buf[IF_LINE_LENGTH];
 -      int len;
 -      char *p;
 -      char *name;
@@ -308,7 +296,7 @@ index 1d84219..f2a8f6d 100644
 -                      log_error("IPv6 interface name '%s' too long", name);
 -                      return 0;
 -              }
--              strcpy(info->name, name);
+-              strncpy(info->name, name, sizeof(info->name) - 1);
 -
 -#ifdef SKIP_DUMMY_INTERFACES
 -      } while (strncmp(info->name, "dummy", 5) == 0);
@@ -346,7 +334,7 @@ index 1d84219..f2a8f6d 100644
 -       * Get our flags.
 -       */
 -      memset(&tmp, 0, sizeof(tmp));
--      strcpy(tmp.ifr_name, name);
+-      strncpy(tmp.ifr_name, name, sizeof(tmp.ifr_name) - 1);
 -      if (ioctl(ifaces->sock, SIOCGIFFLAGS, &tmp) < 0) {
 -              log_error("Error getting interface flags for '%s'; %m", name);
 -              *err = 1;
@@ -367,6 +355,7 @@ index 1d84219..f2a8f6d 100644
 - */
 -int
 -next_iface(struct iface_info *info, int *err, struct iface_conf_list *ifaces) {
+-      memset(info, 0, sizeof(struct iface_info));
 -      if (next_iface4(info, err, ifaces)) {
 -              return 1;
 -      }
@@ -402,11 +391,11 @@ index 1d84219..f2a8f6d 100644
   * -----------
   *
 - * FreeBSD, NetBSD, OpenBSD, and OS X all have the getifaddrs() 
-+ * FreeBSD, NetBSD, OpenBSD, OS X and Linux all have the getifaddrs()
++ * FreeBSD, NetBSD, OpenBSD, OS X and Linux all have the getifaddrs() 
   * function.
   *
   * The getifaddrs() man page describes the use.
-@@ -811,6 +433,8 @@ begin_iface_scan(struct iface_conf_list *ifaces) {
+@@ -806,6 +427,8 @@ begin_iface_scan(struct iface_conf_list
   */
  int
  next_iface(struct iface_info *info, int *err, struct iface_conf_list *ifaces) {
@@ -415,10 +404,10 @@ index 1d84219..f2a8f6d 100644
        if (ifaces->next == NULL) {
                *err = 0;
                return 0;
-@@ -822,8 +446,20 @@ next_iface(struct iface_info *info, int *err, struct iface_conf_list *ifaces) {
-               return 0;
+@@ -818,8 +441,20 @@ next_iface(struct iface_info *info, int
        }
-       strcpy(info->name, ifaces->next->ifa_name);
+       memset(info, 0, sizeof(struct iface_info));
+       strncpy(info->name, ifaces->next->ifa_name, sizeof(info->name) - 1);
 -      memcpy(&info->addr, ifaces->next->ifa_addr, 
 -             ifaces->next->ifa_addr->sa_len);
 +
@@ -438,6 +427,3 @@ index 1d84219..f2a8f6d 100644
        info->flags = ifaces->next->ifa_flags;
        ifaces->next = ifaces->next->ifa_next;
        *err = 0;
--- 
-1.8.1
-