commit:     2ce3a8e57adc2ea9389c35301ce081ab89b42931
Author:     Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
AuthorDate: Fri Aug  9 15:16:40 2019 +0000
Commit:     Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
CommitDate: Fri Aug  9 15:17:03 2019 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=2ce3a8e5

net-misc/dhcpcd: Revbump to fix incorrect string termination

Bug: https://bugs.gentoo.org/691426
Package-Manager: Portage-2.3.71, Repoman-2.3.17
Signed-off-by: Lars Wendler <polynomial-c <AT> gentoo.org>

 ...{dhcpcd-8.0.2.ebuild => dhcpcd-8.0.2-r1.ebuild} |  4 ++
 .../files/dhcpcd-8.0.2-string_termination.patch    | 80 ++++++++++++++++++++++
 2 files changed, 84 insertions(+)

diff --git a/net-misc/dhcpcd/dhcpcd-8.0.2.ebuild 
b/net-misc/dhcpcd/dhcpcd-8.0.2-r1.ebuild
similarity index 98%
rename from net-misc/dhcpcd/dhcpcd-8.0.2.ebuild
rename to net-misc/dhcpcd/dhcpcd-8.0.2-r1.ebuild
index d8940210a7b..1696c38dcf7 100644
--- a/net-misc/dhcpcd/dhcpcd-8.0.2.ebuild
+++ b/net-misc/dhcpcd/dhcpcd-8.0.2-r1.ebuild
@@ -27,6 +27,10 @@ COMMON_DEPEND="udev? ( virtual/udev )"
 DEPEND="${COMMON_DEPEND}"
 RDEPEND="${COMMON_DEPEND}"
 
+PATCHES=(
+       "${FILESDIR}"/${P}-string_termination.patch #691426
+)
+
 src_configure() {
        local myeconfargs=(
                --dbdir="${EPREFIX}/var/lib/dhcpcd"

diff --git a/net-misc/dhcpcd/files/dhcpcd-8.0.2-string_termination.patch 
b/net-misc/dhcpcd/files/dhcpcd-8.0.2-string_termination.patch
new file mode 100644
index 00000000000..a1bc19ec974
--- /dev/null
+++ b/net-misc/dhcpcd/files/dhcpcd-8.0.2-string_termination.patch
@@ -0,0 +1,80 @@
+https://bugs.gentoo.org/691426
+
+diff --git a/src/dhcp-common.c b/src/dhcp-common.c
+index 08ab9493..9f556557 100644
+--- a/src/dhcp-common.c
++++ b/src/dhcp-common.c
+@@ -645,14 +645,16 @@ print_option(FILE *fp, const char *prefix, const struct 
dhcp_opt *opt,
+       if (fputc('=', fp) == EOF)
+               return -1;
+       if (dl == 0)
+-              return 1;
++              goto out;
+ 
+       if (opt->type & OT_RFC1035) {
+               char domain[NS_MAXDNAME];
+ 
+               sl = decode_rfc1035(domain, sizeof(domain), data, dl);
+-              if (sl == 0 || sl == -1)
+-                      return sl;
++              if (sl == -1)
++                      return -1;
++              if (sl == 0)
++                      goto out;
+               if (valid_domainname(domain, opt->type) == -1)
+                       return -1;
+               return efprintf(fp, "%s", domain);
+@@ -693,9 +695,7 @@ print_option(FILE *fp, const char *prefix, const struct 
dhcp_opt *opt,
+                                       return -1;
+                       }
+               }
+-              if (fputc('\0', fp) == EOF)
+-                      return -1;
+-              return 1;
++              goto out;
+       }
+ 
+       t = data;
+@@ -760,6 +760,7 @@ print_option(FILE *fp, const char *prefix, const struct 
dhcp_opt *opt,
+               }
+       }
+ 
++out:
+       if (fputc('\0', fp) == EOF)
+               return -1;
+       return 1;
+diff --git a/src/script.c b/src/script.c
+index 74aef1b1..3dee7b08 100644
+--- a/src/script.c
++++ b/src/script.c
+@@ -33,6 +33,7 @@
+ #include <netinet/in.h>
+ #include <arpa/inet.h>
+ 
++#include <assert.h>
+ #include <ctype.h>
+ #include <errno.h>
+ #include <signal.h>
+@@ -477,12 +478,21 @@ dumplease:
+       fp = NULL;
+ #endif
+ 
++      /* Count the terminated env strings.
++       * assert that the terminations are correct. */
+       nenv = 0;
+       endp = buf + buf_pos;
+       for (bufp = buf; bufp < endp; bufp++) {
+-              if (*bufp == '\0')
++              if (*bufp == '\0') {
++#ifndef NDEBUG
++                      if (bufp + 1 < endp)
++                              assert(*(bufp + 1) != '\0');
++#endif
+                       nenv++;
++              }
+       }
++      assert(*--bufp == '\0');
++
+       if (ctx->script_envlen < nenv) {
+               env = reallocarray(ctx->script_env, nenv + 1, sizeof(*env));
+               if (env == NULL)

Reply via email to