From 8f0af47b27f98682adbf22e4bb68b5d1ced080fd Mon Sep 17 00:00:00 2001 From: tb Date: Fri, 19 Jan 2024 08:28:52 +0000 Subject: [PATCH] coreutils: fix heap buffer overflow This was introduced when improving UBsan reports. Probably a new variety of bugs to be classified in the same family as silencing compiler and coverity warnings. https://marc.info/?l=oss-security&m=170556990821840&w=2 ok bcallah (maintainer) --- sysutils/coreutils/Makefile | 1 + sysutils/coreutils/patches/patch-src_split_c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 sysutils/coreutils/patches/patch-src_split_c diff --git a/sysutils/coreutils/Makefile b/sysutils/coreutils/Makefile index 2fec51c1e9f..45be4b3ba98 100644 --- a/sysutils/coreutils/Makefile +++ b/sysutils/coreutils/Makefile @@ -2,6 +2,7 @@ COMMENT = file, shell and text manipulation utilities DISTNAME = coreutils-9.4 CATEGORIES = sysutils +REVISION = 0 MAINTAINER = Brian Callahan diff --git a/sysutils/coreutils/patches/patch-src_split_c b/sysutils/coreutils/patches/patch-src_split_c new file mode 100644 index 00000000000..4900aa4d03d --- /dev/null +++ b/sysutils/coreutils/patches/patch-src_split_c @@ -0,0 +1,19 @@ +Fix heap buffer overflow + +https://github.com/coreutils/coreutils/commit/c4c5ed8f4e9cd55a12966d4f520e3a13101637d9 +https://marc.info/?l=oss-security&m=170556990821840&w=2 + +Index: src/split.c +--- src/split.c.orig ++++ src/split.c +@@ -809,10 +809,7 @@ line_bytes_split (intmax_t n_bytes, char *buf, idx_t b + { + cwrite (n_out == 0, hold, n_hold); + n_out += n_hold; +- if (n_hold > bufsize) +- hold = xirealloc (hold, bufsize); + n_hold = 0; +- hold_size = bufsize; + } + + /* Output to eol if present. */