aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2021-01-21 15:17:19 +0100
committerNatanael Copa <ncopa@alpinelinux.org>2021-01-21 15:21:41 +0100
commite81a850a352b216e2a803042eb96bdb19b9f59ad (patch)
tree3c9c3d4480275ce1874cd877c72a5d1701ddceb8
parent1defab2cf05c5645eed3a05602732ca24a6040d0 (diff)
downloadaports-e81a850a352b216e2a803042eb96bdb19b9f59ad.tar.gz
aports-e81a850a352b216e2a803042eb96bdb19b9f59ad.tar.bz2
aports-e81a850a352b216e2a803042eb96bdb19b9f59ad.tar.xz
main/busybox: fix echo write error: Invalid argument
ref #12311 https://github.com/alpinelinux/docker-alpine/issues/134
-rw-r--r--main/busybox/0001-echo-do-not-assume-that-free-leaves-errno-unmodified.patch62
-rw-r--r--main/busybox/APKBUILD5
2 files changed, 66 insertions, 1 deletions
diff --git a/main/busybox/0001-echo-do-not-assume-that-free-leaves-errno-unmodified.patch b/main/busybox/0001-echo-do-not-assume-that-free-leaves-errno-unmodified.patch
new file mode 100644
index 0000000000..958222cfc5
--- /dev/null
+++ b/main/busybox/0001-echo-do-not-assume-that-free-leaves-errno-unmodified.patch
@@ -0,0 +1,62 @@
+From 4b7cc6604e7129524a72016ca7b971ad90a81faa Mon Sep 17 00:00:00 2001
+From: Natanael Copa <ncopa@alpinelinux.org>
+Date: Thu, 21 Jan 2021 14:12:51 +0100
+Subject: [PATCH] echo: do not assume that free() leaves errno unmodified
+
+musl libc's mallocng free() may modify errno if kernel does not support
+MADV_FREE which causes echo to echo with error when it shouldn't.
+
+Future versions of POSIX[1] will require that free() leaves errno
+unmodified but til then, do not rely free() implementation.
+
+Should fix downstream issues:
+https://github.com/alpinelinux/docker-alpine/issues/134
+https://gitlab.alpinelinux.org/alpine/aports/-/issues/12311
+
+Bloatcheck on x86_64:
+
+function old new delta
+echo_main 414 406 -8
+------------------------------------------------------------------------------
+(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-8) Total: -8
+bytes
+ text data bss dec hex filename
+ 881114 15196 2000 898310 db506 busybox_old
+ 881106 15196 2000 898302 db4fe busybox_unstripped
+---
+ coreutils/echo.c | 9 ++++-----
+ 1 file changed, 4 insertions(+), 5 deletions(-)
+
+diff --git a/coreutils/echo.c b/coreutils/echo.c
+index b3828894c..9e8939a00 100644
+--- a/coreutils/echo.c
++++ b/coreutils/echo.c
+@@ -97,6 +97,7 @@ int echo_main(int argc UNUSED_PARAM, char **argv)
+ #else
+ char nflag = 1;
+ char eflag = 0;
++ int err;
+
+ while ((arg = *++argv) != NULL) {
+ char n, e;
+@@ -184,14 +185,12 @@ int echo_main(int argc UNUSED_PARAM, char **argv)
+
+ do_write:
+ /* Careful to error out on partial writes too (think ENOSPC!) */
+- errno = 0;
+- /*r =*/ full_write(STDOUT_FILENO, buffer, out - buffer);
++ err = full_write(STDOUT_FILENO, buffer, out - buffer) != out - buffer;
+ free(buffer);
+- if (/*WRONG:r < 0*/ errno) {
++ if (err) {
+ bb_simple_perror_msg(bb_msg_write_error);
+- return 1;
+ }
+- return 0;
++ return err;
+ }
+
+ /*
+--
+2.30.0
+
diff --git a/main/busybox/APKBUILD b/main/busybox/APKBUILD
index ecfee1c6cf..6a43eab8be 100644
--- a/main/busybox/APKBUILD
+++ b/main/busybox/APKBUILD
@@ -4,7 +4,7 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=busybox
pkgver=1.32.1
-pkgrel=0
+pkgrel=1
pkgdesc="Size optimized toolbox of many common UNIX utilities"
url="https://busybox.net/"
arch="all"
@@ -35,6 +35,8 @@ source="https://busybox.net/downloads/busybox-$pkgver.tar.bz2
0010-Add-flag-for-not-following-symlinks-when-recursing.patch
0012-udhcpc-Don-t-background-if-n-is-given.patch
+ 0001-echo-do-not-assume-that-free-leaves-errno-unmodified.patch
+
acpid.logrotate
busyboxconfig
busyboxconfig-extras
@@ -233,6 +235,7 @@ e4be12a1453a306a58c4ea59cd8a0bf1f261514ae090ea962ac6f7609dc1e9dab0d4d8d351d7adf4
df02adb3e3cd3349cc8d070911e3392164cb2e30bd72cae7ceaa974b2db6f958fdcedf809abc7b4bee37c729a4d20abf127f615b0e238a667d572137abe6a79e 0009-depmod-support-generating-kmod-binary-index-files.patch
3b13ba6bd9b697e48864cb5376849c1ac95b30650e3e27605cc05edf4fdc1ecbb4c4503d4fe9012a581bcd660f6bb44d644575cf437d30423614cb83ee92c22c 0010-Add-flag-for-not-following-symlinks-when-recursing.patch
4d043999ffbf6875e6b28ffdb43a36dd5d37d51e862ed7d89c6007e38cdda056292c5322a3ac3189fd489bf3ad1cce7b20508a96aee55c09f09354e1c3f5f5fe 0012-udhcpc-Don-t-background-if-n-is-given.patch
+e8c8c049b0145e75963638311e80962f9b226e5b664ec35fe001fcc42e3ebc44421c7abc8e975882035eaaa3e03d813ad43255c65f07641463409ce4ea29ea76 0001-echo-do-not-assume-that-free-leaves-errno-unmodified.patch
aa93095e20de88730f526c6f463cef711b290b9582cdbd8c1ba2bd290019150cbeaa7007c2e15f0362d5b9315dd63f60511878f0ea05e893f4fdfb4a54af3fb1 acpid.logrotate
2f093f620b6d9dcef6e2e00c5395143b6497882653b4155ff313dff26210be91059cabafc606324c0230e80a461e0560839b14bf37e20671a7b8762f488b6c8f busyboxconfig
931e628184a25ae29760f7853c15c570dfb33075af167346e9662b9c7c5829e834ec81027bb10526c376261d229152bb096eb741cea0a5c0e3c614dd2c9d287e busyboxconfig-extras