aboutsummaryrefslogtreecommitdiffstats
path: root/main/musl
diff options
context:
space:
mode:
authorWilliam Pitcock <nenolod@dereferenced.org>2017-11-17 21:10:34 +0000
committerWilliam Pitcock <nenolod@dereferenced.org>2017-11-17 21:11:10 +0000
commit036898cc239499f2dbf57d6230e842947b99882d (patch)
tree796c0eff98903c3811220f1db249557f4ea47a25 /main/musl
parent9949cdbaf2d26500ed011ee266370c83e048ff90 (diff)
downloadaports-036898cc239499f2dbf57d6230e842947b99882d.tar.bz2
aports-036898cc239499f2dbf57d6230e842947b99882d.tar.xz
main/musl: update fopencookie patch to v9
dalias actually likes this version, so hopefully it should be in musl soon
Diffstat (limited to 'main/musl')
-rw-r--r--main/musl/3002-stdio-implement-fopencookie-3.patch48
-rw-r--r--main/musl/APKBUILD4
2 files changed, 28 insertions, 24 deletions
diff --git a/main/musl/3002-stdio-implement-fopencookie-3.patch b/main/musl/3002-stdio-implement-fopencookie-3.patch
index 4b863e9095..881a86a16b 100644
--- a/main/musl/3002-stdio-implement-fopencookie-3.patch
+++ b/main/musl/3002-stdio-implement-fopencookie-3.patch
@@ -1,4 +1,4 @@
-From 1f6d9870ebc905990d230a3887d2e91a9edfde93 Mon Sep 17 00:00:00 2001
+From f501fa8271c7464c9c75762d2c9f43e494e416d8 Mon Sep 17 00:00:00 2001
From: William Pitcock <nenolod@dereferenced.org>
Date: Sun, 24 Sep 2017 16:37:48 -0500
Subject: [PATCH] stdio: implement fopencookie(3)
@@ -9,6 +9,13 @@ stdio implementation, using four hook functions which operate on a
Changelog:
+v9:
+- make read function more robust, should have been in v8 but i forgot to commit
+
+v8:
+- fix possible ungetc() underflow
+- style cleanups
+
v7:
- include GNU typedefs for cookie i/o functions
@@ -38,8 +45,8 @@ v1:
- initial proof of concept
---
include/stdio.h | 14 +++++
- src/stdio/fopencookie.c | 141 ++++++++++++++++++++++++++++++++++++++++++++++++
- 2 files changed, 155 insertions(+)
+ src/stdio/fopencookie.c | 138 ++++++++++++++++++++++++++++++++++++++++++++++++
+ 2 files changed, 152 insertions(+)
create mode 100644 src/stdio/fopencookie.c
diff --git a/include/stdio.h b/include/stdio.h
@@ -69,10 +76,10 @@ index 884d2e6a..2932c76f 100644
#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
diff --git a/src/stdio/fopencookie.c b/src/stdio/fopencookie.c
new file mode 100644
-index 00000000..bcf42c10
+index 00000000..2f46dd53
--- /dev/null
+++ b/src/stdio/fopencookie.c
-@@ -0,0 +1,141 @@
+@@ -0,0 +1,138 @@
+#define _GNU_SOURCE
+#include "stdio_impl.h"
+#include <stdlib.h>
@@ -97,31 +104,31 @@ index 00000000..bcf42c10
+ struct fcookie *fc = f->cookie;
+ ssize_t ret = -1;
+ size_t remain = len, readlen = 0;
++ size_t len2 = len - !!f->buf_size;
+
+ if (!fc->iofuncs.read) goto bail;
+
-+ ret = fc->iofuncs.read(fc->cookie, (char *) buf, len > 1 ? (len - 1) : 1);
-+ if (ret <= 0) goto bail;
++ if (len2) {
++ ret = fc->iofuncs.read(fc->cookie, (char *) buf, len2);
++ if (ret <= 0) goto bail;
+
-+ readlen += ret;
-+ remain -= ret;
++ readlen += ret;
++ remain -= ret;
++ }
++
++ if (!f->buf_size || remain > !!f->buf_size) return readlen;
+
+ f->rpos = f->buf;
+ ret = fc->iofuncs.read(fc->cookie, (char *) f->rpos, f->buf_size);
+ if (ret <= 0) goto bail;
+ f->rend = f->rpos + ret;
+
-+ if (remain > 0) {
-+ if (remain > f->buf_size) remain = f->buf_size;
-+ memcpy(buf + readlen, f->rpos, remain);
-+ readlen += remain;
-+ f->rpos += remain;
-+ }
++ buf[readlen++] = *f->rpos++;
+
+ return readlen;
+
+bail:
-+ f->flags |= F_EOF ^ ((F_ERR^F_EOF) & ret);
++ f->flags |= ret == 0 ? F_EOF : F_ERR;
+ f->rpos = f->rend = f->buf;
+ return readlen;
+}
@@ -149,7 +156,7 @@ index 00000000..bcf42c10
+{
+ struct fcookie *fc = f->cookie;
+ int res;
-+ if (whence > 2) {
++ if (whence > 2U) {
+ errno = EINVAL;
+ return -1;
+ }
@@ -184,7 +191,7 @@ index 00000000..bcf42c10
+ if (!(f=malloc(sizeof *f))) return 0;
+
+ /* Zero-fill only the struct, not the buffer */
-+ memset(f, 0, sizeof(FILE));
++ memset(&f->f, 0, sizeof f->f);
+
+ /* Impose mode restrictions */
+ if (!strchr(mode, '+')) f->f.flags = (*mode == 'r') ? F_NOWR : F_NORD;
@@ -198,13 +205,10 @@ index 00000000..bcf42c10
+
+ f->f.fd = -1;
+ f->f.cookie = &f->fc;
-+ f->f.buf = f->buf;
++ f->f.buf = f->buf + UNGET;
+ f->f.buf_size = BUFSIZ;
+ f->f.lbf = EOF;
+
-+ /* enable opportunistic stdio locking */
-+ f->f.lock = 0;
-+
+ /* Initialize op ptrs. No problem if some are unneeded. */
+ f->f.read = cookieread;
+ f->f.write = cookiewrite;
diff --git a/main/musl/APKBUILD b/main/musl/APKBUILD
index 8370169012..2c6ca6340e 100644
--- a/main/musl/APKBUILD
+++ b/main/musl/APKBUILD
@@ -2,7 +2,7 @@
# Maintainer: Timo Teräs <timo.teras@iki.fi>
pkgname=musl
pkgver=1.1.18
-pkgrel=1
+pkgrel=2
pkgdesc="the musl c library (libc) implementation"
url="http://www.musl-libc.org/"
arch="all"
@@ -145,7 +145,7 @@ compat() {
sha512sums="4d55c92efe41dfdd9fff6aca5dda76a632a3be60d10e5a7f66a4731d8f7040fb0a20b998965ba4d069b4f8a3527fcd7388e646cb66afc649c4d0cc6c3d358c9c musl-1.1.18.tar.gz
7e4c703e57a3564cd3ee1d5334b806cbe654355179ba55d4d25361dfc555eb4a7d081d80d64fdaff8476949afd04558d278b124d1fb108080beaa5ba2f8ce2b9 1000-implement-strftime-GNU-extension-padding-specifiers-.patch
2c8e1dde1834238097b2ee8a7bfb53471a0d9cff4a5e38b55f048b567deff1cdd47c170d0578a67b1a039f95a6c5fbb8cff369c75b6a3e4d7ed171e8e86ebb8c 2000-pthread-internals-increase-DEFAULT_GUARD_SIZE-to-2-p.patch
-30e7fdbdb5fd18d6b2d49b0277ca62d253a52087938b0f4ff75fba278ee3adcaae219043db130f8acd24713a8e2345aceda28d2f6a7d49de2d3ae8fba0eba924 3002-stdio-implement-fopencookie-3.patch
+bdc6fe197779088507d6f8bb72560239f908a635b39eb677bfcf91da28b92ee52b67696e627dad08ccb8a7dcaf7a72b574276098fb3fddd4a6b646a0f0799785 3002-stdio-implement-fopencookie-3.patch
8d3a2d5315fc56fee7da9abb8b89bb38c6046c33d154c10d168fb35bfde6b0cf9f13042a3bceee34daf091bc409d699223735dcf19f382eeee1f6be34154f26f ldconfig
062bb49fa54839010acd4af113e20f7263dde1c8a2ca359b5fb2661ef9ed9d84a0f7c3bc10c25dcfa10bb3c5a4874588dff636ac43d5dbb3d748d75400756d0b __stack_chk_fail_local.c
0d80f37b34a35e3d14b012257c50862dfeb9d2c81139ea2dfa101d981d093b009b9fa450ba27a708ac59377a48626971dfc58e20a3799084a65777a0c32cbc7d getconf.c