aboutsummaryrefslogtreecommitdiffstats
path: root/toolchain/musl/patches/066-fix-swprintf-internal-buffer-state-and-error-handling.patch
diff options
context:
space:
mode:
authorKoen Vandeputte <koen.vandeputte@ncentric.com>2016-12-22 17:17:04 +0100
committerFelix Fietkau <nbd@nbd.name>2016-12-26 11:17:33 +0100
commit2912f9f2a2e5997df069d38e20d85ff4cc51acef (patch)
tree783e8cd472936ac1ca9378f16fb3189a486e7a48 /toolchain/musl/patches/066-fix-swprintf-internal-buffer-state-and-error-handling.patch
parentb97c933ffb5aae338351a1db12a3f7cf5234f5c7 (diff)
downloadupstream-2912f9f2a2e5997df069d38e20d85ff4cc51acef.tar.gz
upstream-2912f9f2a2e5997df069d38e20d85ff4cc51acef.tar.bz2
upstream-2912f9f2a2e5997df069d38e20d85ff4cc51acef.zip
musl: backport various post-1.1.15 fixes
Backport most important fixes up to latest HEAD - Taken post-commit reverts/fixes into account Compile tested Run-tested on cns3xxx & imx6 targets Signed-off-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
Diffstat (limited to 'toolchain/musl/patches/066-fix-swprintf-internal-buffer-state-and-error-handling.patch')
-rw-r--r--toolchain/musl/patches/066-fix-swprintf-internal-buffer-state-and-error-handling.patch36
1 files changed, 36 insertions, 0 deletions
diff --git a/toolchain/musl/patches/066-fix-swprintf-internal-buffer-state-and-error-handling.patch b/toolchain/musl/patches/066-fix-swprintf-internal-buffer-state-and-error-handling.patch
new file mode 100644
index 0000000000..a6e7c7f5b0
--- /dev/null
+++ b/toolchain/musl/patches/066-fix-swprintf-internal-buffer-state-and-error-handling.patch
@@ -0,0 +1,36 @@
+From 7442442ccc665641a8827177e8e7ed45bbbd6584 Mon Sep 17 00:00:00 2001
+From: Rich Felker <dalias@aerifal.cx>
+Date: Mon, 7 Nov 2016 20:39:59 -0500
+Subject: fix swprintf internal buffer state and error handling
+
+the swprintf write callback never reset its buffer pointers, so after
+its 256-byte buffer filled up, it would keep repeating those bytes
+over and over in the output until the destination buffer filled up. it
+also failed to set the error indicator for the stream on EILSEQ,
+potentially allowing output to continue after the error.
+---
+ src/stdio/vswprintf.c | 9 ++++++++-
+ 1 file changed, 8 insertions(+), 1 deletion(-)
+
+diff --git a/src/stdio/vswprintf.c b/src/stdio/vswprintf.c
+index 7d237ba..6eb2f6a 100644
+--- a/src/stdio/vswprintf.c
++++ b/src/stdio/vswprintf.c
+@@ -24,7 +24,14 @@ static size_t sw_write(FILE *f, const unsigned char *s, size_t l)
+ c->ws++;
+ }
+ *c->ws = 0;
+- return i<0 ? i : l0;
++ if (i < 0) {
++ f->wpos = f->wbase = f->wend = 0;
++ f->flags |= F_ERR;
++ return i;
++ }
++ f->wend = f->buf + f->buf_size;
++ f->wpos = f->wbase = f->buf;
++ return l0;
+ }
+
+ int vswprintf(wchar_t *restrict s, size_t n, const wchar_t *restrict fmt, va_list ap)
+--
+cgit v0.11.2