]> git.ipfire.org Git - people/mlorenz/ipfire-2.x.git/blobdiff - src/patches/dhcpcd-10.0.2-fix-off-by-one-overflow-when-read.patch
dhcpcd: Fix buffer overflow at startup
[people/mlorenz/ipfire-2.x.git] / src / patches / dhcpcd-10.0.2-fix-off-by-one-overflow-when-read.patch
diff --git a/src/patches/dhcpcd-10.0.2-fix-off-by-one-overflow-when-read.patch b/src/patches/dhcpcd-10.0.2-fix-off-by-one-overflow-when-read.patch
new file mode 100644 (file)
index 0000000..9e9cf36
--- /dev/null
@@ -0,0 +1,26 @@
+From f798bf23af8e5a0eae38931912e2b67e1d45aca4 Mon Sep 17 00:00:00 2001
+From: Tobias Heider <tobhe@users.noreply.github.com>
+Date: Sat, 12 Aug 2023 21:59:21 +0200
+Subject: [PATCH] dhcpcd: Fix off-by-one overflow when read() writes full
+ BUFSIZ (#236)
+
+---
+ src/dhcpcd.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/dhcpcd.c b/src/dhcpcd.c
+index e06733d3..688a3a6d 100644
+--- a/src/dhcpcd.c
++++ b/src/dhcpcd.c
+@@ -1822,7 +1822,7 @@ dhcpcd_stderr_cb(void *arg, unsigned short events)
+       if (!(events & ELE_READ))
+               return;
+-      len = read(ctx->stderr_fd, log, sizeof(log));
++      len = read(ctx->stderr_fd, log, sizeof(log) - 1);
+       if (len == -1) {
+               if (errno != ECONNRESET)
+                       logerr(__func__);
+-- 
+2.39.2
+