aboutsummaryrefslogtreecommitdiffstats
path: root/main/ca-certificates
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2016-04-08 10:46:12 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2016-04-08 10:46:12 +0000
commit447c5aa36c467893598124fc0899c7c0bdbaf957 (patch)
treee5135dc8ef7bb8816b7b3a6aa6e8520eb1c3353d /main/ca-certificates
parentaa345961cfcaeb6b3e66f340d890621c3fa79235 (diff)
downloadaports-447c5aa36c467893598124fc0899c7c0bdbaf957.tar.bz2
aports-447c5aa36c467893598124fc0899c7c0bdbaf957.tar.xz
main/ca-certificates: sendfile fix update-ca-certificates
fallback to read(2)/write(2) in case sendfile is not supported by kernel or blockdevice/filesystem
Diffstat (limited to 'main/ca-certificates')
-rw-r--r--main/ca-certificates/APKBUILD8
-rw-r--r--main/ca-certificates/update-ca.c36
2 files changed, 39 insertions, 5 deletions
diff --git a/main/ca-certificates/APKBUILD b/main/ca-certificates/APKBUILD
index 72411392df..808dced2f3 100644
--- a/main/ca-certificates/APKBUILD
+++ b/main/ca-certificates/APKBUILD
@@ -2,7 +2,7 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=ca-certificates
pkgver=20160104
-pkgrel=2
+pkgrel=3
pkgdesc="Common CA certificates PEM files"
url="http://packages.debian.org/sid/ca-certificates"
arch="all"
@@ -78,10 +78,10 @@ EOF
md5sums="d9665a83d0d3ef8176a38e6aa20458e9 ca-certificates_20160104.tar.xz
0c3d9f5d795c7475b997e18498b7aec8 fix-manpage.patch
-d7773c690432a56911c0fa97a67bf43e update-ca.c"
+1fd207560aa262721892abac1b88e497 update-ca.c"
sha256sums="09eb770122e23260316120c0cbbddc8a1d33e7147210ce44e146084d5d5abcdd ca-certificates_20160104.tar.xz
60b36c4881bb367891df038a0736456c2d170496de8c339026671008b1caa09b fix-manpage.patch
-b2231e7f0304d6360350f1f1aa9afad46fe4eeb0f0306a48eeb8cd74501ab26c update-ca.c"
+39648ec37f7d282050a5ce2b942fa6d4eb6abd20723be773f61f95f518318343 update-ca.c"
sha512sums="4291ba58057b66d56853162b71862832135eab6f444a5e2cf3dd1089495d44624246dc0c540871851fe9aaceb42054516309402525c8f16a88911d3af9c3518a ca-certificates_20160104.tar.xz
690d6bb434fb3ccce931d7ee6a167124f9c2d2e7e7a016d85f7b72a5f7f7c34db8c6133f3575e962a91981a32a88f8961776fe5fd907e57f59c03a32f2fcced3 fix-manpage.patch
-403c909ea4107d944789b8aae9c911c735ac651cf882bf8468e0f91b3179700a78cabcbec16e3ae0bed730b54d1813d5d0891c1aeae583ad80c7a20b0f425b12 update-ca.c"
+4459e7596a8c2b815fcd2fbdd8eee9a2a626932a0295340554c7bbdfddf43c074a6eefab8dd6198d82e1d766a985623f4204a7488a157d8e62876a55749aaaca update-ca.c"
diff --git a/main/ca-certificates/update-ca.c b/main/ca-certificates/update-ca.c
index 20af994c38..4451217e7a 100644
--- a/main/ca-certificates/update-ca.c
+++ b/main/ca-certificates/update-ca.c
@@ -6,6 +6,7 @@
#include <dirent.h>
#include <unistd.h>
#include <fcntl.h>
+#include <errno.h>
#include <sys/stat.h>
#include <sys/sendfile.h>
@@ -95,6 +96,37 @@ static bool hash_add(struct hash *h, const char *key, const char *value)
return true;
}
+static ssize_t
+buffered_copyfd(int in_fd, int out_fd, ssize_t in_size)
+{
+ const size_t bufsize = 8192;
+ char *buf = NULL;
+ ssize_t r = 0, w = 0, copied = 0, n, m;
+ if ((buf = malloc(bufsize)) == NULL)
+ return -1;
+
+ while (r < in_size && (n = read(in_fd, buf, bufsize))) {
+ if (n == -1) {
+ if (errno == EINTR)
+ continue;
+ break;
+ }
+ r = n;
+ w = 0;
+ while (w < r && (n = write(out_fd, buf + w, (r - w)))) {
+ if (n == -1) {
+ if (errno == EINTR)
+ continue;
+ break;
+ }
+ w += n;
+ }
+ copied += w;
+ }
+ free(buf);
+ return copied;
+}
+
static bool
copyfile(const char* source, int output)
{
@@ -112,8 +144,10 @@ copyfile(const char* source, int output)
}
result = sendfile(output, in_fd, &bytes, fileinfo.st_size);
- close(in_fd);
+ if (result == EINVAL || result == ENOSYS)
+ result = buffered_copyfd(in_fd, output, fileinfo.st_size);
+ close(in_fd);
return fileinfo.st_size == result;
}