summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin McAllister <colinmca242@gmail.com>2024-09-14 09:05:16 -0500
committerSteve Sakoman <steve@sakoman.com>2024-09-27 05:57:35 -0700
commit30d00daf9e542585c7a42b94d717d6463a610ac0 (patch)
treeec7254f9623675c2d356f9c0594e817b717447b2
parent487e8cdf1df6feba6d88fa29e11791f4ebaaa362 (diff)
downloadpoky-30d00daf9e542585c7a42b94d717d6463a610ac0.tar.gz
busybox: Fix cut with "-s" flag
This fixes and issue that allows blank lines to be incorrectly output when the "-s" flag is included. This issue propogates into the populate-volatile.sh script in initscripts. If a volatiles drop file contains blank lines, a blank line will be included in combined users, which will incorrectly result in a difference in the number of combined users versus defined users. If this happens, the volatiles file will not be executed. (From OE-Core rev: dfbcf0581ab3dd47037726a7b8aa06f777792473) (From OE-Core rev: 5576ff6e7676a09649fdbf0042f5f64a1ec1023b) Signed-off-by: Colin McAllister <colinmca242@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> Signed-off-by: Steve Sakoman <steve@sakoman.com>
-rw-r--r--meta/recipes-core/busybox/busybox/0001-cut-Fix-s-flag-to-omit-blank-lines.patch66
-rw-r--r--meta/recipes-core/busybox/busybox_1.35.0.bb1
2 files changed, 67 insertions, 0 deletions
diff --git a/meta/recipes-core/busybox/busybox/0001-cut-Fix-s-flag-to-omit-blank-lines.patch b/meta/recipes-core/busybox/busybox/0001-cut-Fix-s-flag-to-omit-blank-lines.patch
new file mode 100644
index 0000000000..a0a8607b23
--- /dev/null
+++ b/meta/recipes-core/busybox/busybox/0001-cut-Fix-s-flag-to-omit-blank-lines.patch
@@ -0,0 +1,66 @@
1From 199606e960942c29fd8085be812edd3d3697825c Mon Sep 17 00:00:00 2001
2From: Colin McAllister <colinmca242@gmail.com>
3Date: Wed, 17 Jul 2024 07:58:52 -0500
4Subject: [PATCH 1/1] cut: Fix "-s" flag to omit blank lines
5
6Using cut with the delimiter flag ("-d") with the "-s" flag to only
7output lines containing the delimiter will print blank lines. This is
8deviant behavior from cut provided by GNU Coreutils. Blank lines should
9be omitted if "-s" is used with "-d".
10
11This change introduces a somewhat naiive, yet efficient solution, where
12line length is checked before looping though bytes. If line length is
13zero and the "-s" flag is used, the code will jump to parsing the next
14line to avoid printing a newline character.
15
16In addition, a test to cut.tests has been added to ensure that this
17regression is fixed and will not happen again in the future.
18
19Upstream-Status: Submitted [http://lists.busybox.net/pipermail/busybox/2024-July/090834.html]
20
21Signed-off-by: Colin McAllister <colinmca242@gmail.com>
22---
23 coreutils/cut.c | 6 ++++++
24 testsuite/cut.tests | 9 +++++++++
25 2 files changed, 15 insertions(+)
26
27diff --git a/coreutils/cut.c b/coreutils/cut.c
28index 55bdd9386..b7f986f26 100644
29--- a/coreutils/cut.c
30+++ b/coreutils/cut.c
31@@ -152,6 +152,12 @@ static void cut_file(FILE *file, const char *delim, const char *odelim,
32 unsigned uu = 0, start = 0, end = 0, out = 0;
33 int dcount = 0;
34
35+ /* Blank line? */
36+ if (!linelen) {
37+ if (option_mask32 & CUT_OPT_SUPPRESS_FLGS)
38+ goto next_line;
39+ }
40+
41 /* Loop through bytes, finding next delimiter */
42 for (;;) {
43 /* End of current range? */
44diff --git a/testsuite/cut.tests b/testsuite/cut.tests
45index 2458c019c..0b401bc00 100755
46--- a/testsuite/cut.tests
47+++ b/testsuite/cut.tests
48@@ -65,6 +65,15 @@ testing "cut with -d -f( ) -s" "cut -d' ' -f3 -s input && echo yes" "yes\n" "$in
49 testing "cut with -d -f(a) -s" "cut -da -f3 -s input" "n\nsium:Jim\n\ncion:Ed\n" "$input" ""
50 testing "cut with -d -f(a) -s -n" "cut -da -f3 -s -n input" "n\nsium:Jim\n\ncion:Ed\n" "$input" ""
51
52+input="\
53+
54+foo bar baz
55+
56+bing bong boop
57+
58+"
59+testing "cut with -d -s omits blank lines" "cut -d' ' -f2 -s input" "bar\nbong\n" "$input" ""
60+
61 # substitute for awk
62 optional FEATURE_CUT_REGEX
63 testing "cut -DF" "cut -DF 2,7,5" \
64--
652.43.0
66
diff --git a/meta/recipes-core/busybox/busybox_1.35.0.bb b/meta/recipes-core/busybox/busybox_1.35.0.bb
index dbcefbb274..6bffbbb5a8 100644
--- a/meta/recipes-core/busybox/busybox_1.35.0.bb
+++ b/meta/recipes-core/busybox/busybox_1.35.0.bb
@@ -57,6 +57,7 @@ SRC_URI = "https://busybox.net/downloads/busybox-${PV}.tar.bz2;name=tarball \
57 file://CVE-2023-42364_42365-1.patch \ 57 file://CVE-2023-42364_42365-1.patch \
58 file://CVE-2023-42364_42365-2.patch \ 58 file://CVE-2023-42364_42365-2.patch \
59 file://CVE-2023-42366.patch \ 59 file://CVE-2023-42366.patch \
60 file://0001-cut-Fix-s-flag-to-omit-blank-lines.patch \
60 " 61 "
61SRC_URI:append:libc-musl = " file://musl.cfg " 62SRC_URI:append:libc-musl = " file://musl.cfg "
62 63