summaryrefslogtreecommitdiff
path: root/pkg/openbsd/patch/0028-rsync-Avoid-pointer-arithmetic-on-void.patch
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/openbsd/patch/0028-rsync-Avoid-pointer-arithmetic-on-void.patch')
-rw-r--r--pkg/openbsd/patch/0028-rsync-Avoid-pointer-arithmetic-on-void.patch105
1 files changed, 49 insertions, 56 deletions
diff --git a/pkg/openbsd/patch/0028-rsync-Avoid-pointer-arithmetic-on-void.patch b/pkg/openbsd/patch/0028-rsync-Avoid-pointer-arithmetic-on-void.patch
index 11e3ca97..885ce499 100644
--- a/pkg/openbsd/patch/0028-rsync-Avoid-pointer-arithmetic-on-void.patch
+++ b/pkg/openbsd/patch/0028-rsync-Avoid-pointer-arithmetic-on-void.patch
@@ -1,52 +1,60 @@
-From 33c8f9c16352f016423b4f67ec851318506c17e3 Mon Sep 17 00:00:00 2001
+From bae6ab2cb50b4c5784dcd17207f145707c77f317 Mon Sep 17 00:00:00 2001
From: Michael Forney <mforney@mforney.org>
Date: Sat, 15 Jun 2019 20:06:13 -0700
Subject: [PATCH] rsync: Avoid pointer arithmetic on `void *`
---
- usr.bin/rsync/blocks.c | 6 +++---
+ usr.bin/rsync/blocks.c | 8 ++++----
usr.bin/rsync/downloader.c | 2 +-
usr.bin/rsync/io.c | 12 ++++++------
usr.bin/rsync/sender.c | 4 ++--
- usr.bin/rsync/uploader.c | 4 ++--
- 5 files changed, 14 insertions(+), 14 deletions(-)
+ 4 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/usr.bin/rsync/blocks.c b/usr.bin/rsync/blocks.c
-index d02f4f40b4b..9c163600307 100644
+index 4f21a41833d..242590e5bae 100644
--- a/usr.bin/rsync/blocks.c
+++ b/usr.bin/rsync/blocks.c
-@@ -54,7 +54,7 @@ blk_find(struct sess *sess, const void *buf, off_t size, off_t offs,
- remain = size - offs;
- assert(remain);
- osz = remain < (off_t)blks->len ? remain : (off_t)blks->len;
-- fhash = hash_fast(buf + offs, (size_t)osz);
-+ fhash = hash_fast((char *)buf + offs, (size_t)osz);
- have_md = 0;
-
- /*
-@@ -65,7 +65,7 @@ blk_find(struct sess *sess, const void *buf, off_t size, off_t offs,
- if (hint < blks->blksz &&
- fhash == blks->blks[hint].chksum_short &&
- (size_t)osz == blks->blks[hint].len) {
-- hash_slow(buf + offs, (size_t)osz, md, sess);
-+ hash_slow((char *)buf + offs, (size_t)osz, md, sess);
+@@ -157,7 +157,7 @@ blk_find(struct sess *sess, struct blkstat *st,
+ if (!recomp) {
+ fhash = (st->s1 & 0xFFFF) | (st->s2 << 16);
+ } else {
+- fhash = hash_fast(st->map + st->offs, (size_t)osz);
++ fhash = hash_fast((char *)st->map + st->offs, (size_t)osz);
+ st->s1 = fhash & 0xFFFF;
+ st->s2 = fhash >> 16;
+ }
+@@ -170,7 +170,7 @@ blk_find(struct sess *sess, struct blkstat *st,
+ if (st->hint < blks->blksz &&
+ fhash == blks->blks[st->hint].chksum_short &&
+ (size_t)osz == blks->blks[st->hint].len) {
+- hash_slow(st->map + st->offs, (size_t)osz, md, sess);
++ hash_slow((char *)st->map + st->offs, (size_t)osz, md, sess);
have_md = 1;
- if (memcmp(md, blks->blks[hint].chksum_long, blks->csum) == 0) {
- LOG4(sess, "%s: found matching hinted match: "
-@@ -99,7 +99,7 @@ blk_find(struct sess *sess, const void *buf, off_t size, off_t offs,
- /* Compute slow hash on demand. */
+ if (memcmp(md, blks->blks[st->hint].chksum_long, blks->csum) == 0) {
+ LOG4("%s: found matching hinted match: "
+@@ -203,7 +203,7 @@ blk_find(struct sess *sess, struct blkstat *st,
+ (intmax_t)ent->blk->offs, ent->blk->len);
if (have_md == 0) {
-- hash_slow(buf + offs, (size_t)osz, md, sess);
-+ hash_slow((char *)buf + offs, (size_t)osz, md, sess);
+- hash_slow(st->map + st->offs, (size_t)osz, md, sess);
++ hash_slow((char *)st->map + st->offs, (size_t)osz, md, sess);
have_md = 1;
}
+@@ -221,7 +221,7 @@ blk_find(struct sess *sess, struct blkstat *st,
+ * block in the sequence.
+ */
+
+- map = st->map + st->offs;
++ map = (char *)st->map + st->offs;
+ st->s1 -= map[0];
+ st->s2 -= osz * map[0];
+
diff --git a/usr.bin/rsync/downloader.c b/usr.bin/rsync/downloader.c
-index 405f7623759..f47c895957d 100644
+index 9ddb8600a73..36b086f74c8 100644
--- a/usr.bin/rsync/downloader.c
+++ b/usr.bin/rsync/downloader.c
-@@ -497,7 +497,7 @@ again:
+@@ -495,7 +495,7 @@ again:
sz = tok == p->blk.blksz - 1 ? p->blk.rem : p->blk.len;
assert(sz);
assert(p->map != MAP_FAILED);
@@ -56,11 +64,11 @@ index 405f7623759..f47c895957d 100644
/*
* Now we read from our block.
diff --git a/usr.bin/rsync/io.c b/usr.bin/rsync/io.c
-index 0e451226d31..404e7bf4112 100644
+index 8d113d6d013..181458ced08 100644
--- a/usr.bin/rsync/io.c
+++ b/usr.bin/rsync/io.c
-@@ -117,7 +117,7 @@ io_write_blocking(struct sess *sess, int fd, const void *buf, size_t sz)
- ERRX(sess, "io_write_nonblocking: short write");
+@@ -117,7 +117,7 @@ io_write_blocking(int fd, const void *buf, size_t sz)
+ ERRX("io_write_nonblocking: short write");
return 0;
}
- buf += wsz;
@@ -77,8 +85,8 @@ index 0e451226d31..404e7bf4112 100644
}
return 1;
-@@ -252,7 +252,7 @@ io_read_blocking(struct sess *sess,
- ERRX(sess, "io_read_nonblocking: short read");
+@@ -250,7 +250,7 @@ io_read_blocking(int fd, void *buf, size_t sz)
+ ERRX("io_read_nonblocking: short read");
return 0;
}
- buf += rsz;
@@ -86,7 +94,7 @@ index 0e451226d31..404e7bf4112 100644
sz -= rsz;
}
-@@ -369,7 +369,7 @@ io_read_buf(struct sess *sess, int fd, void *buf, size_t sz)
+@@ -367,7 +367,7 @@ io_read_buf(struct sess *sess, int fd, void *buf, size_t sz)
}
sz -= rsz;
sess->mplex_read_remain -= rsz;
@@ -95,7 +103,7 @@ index 0e451226d31..404e7bf4112 100644
sess->total_read += rsz;
continue;
}
-@@ -465,7 +465,7 @@ io_buffer_buf(struct sess *sess, void *buf,
+@@ -463,7 +463,7 @@ io_buffer_buf(void *buf, size_t *bufpos, size_t buflen, const void *val,
{
assert(*bufpos + valsz <= buflen);
@@ -104,7 +112,7 @@ index 0e451226d31..404e7bf4112 100644
*bufpos += valsz;
}
-@@ -664,7 +664,7 @@ io_unbuffer_buf(struct sess *sess, const void *buf,
+@@ -661,7 +661,7 @@ io_unbuffer_buf(const void *buf, size_t *bufpos, size_t bufsz, void *val,
{
assert(*bufpos + valsz <= bufsz);
@@ -114,7 +122,7 @@ index 0e451226d31..404e7bf4112 100644
}
diff --git a/usr.bin/rsync/sender.c b/usr.bin/rsync/sender.c
-index ab7221a87d7..8b48ab7cc81 100644
+index 5f9850ee9d2..d6a1f55d1a9 100644
--- a/usr.bin/rsync/sender.c
+++ b/usr.bin/rsync/sender.c
@@ -128,7 +128,7 @@ send_up_fsm(struct sess *sess, size_t *phase,
@@ -126,30 +134,15 @@ index ab7221a87d7..8b48ab7cc81 100644
up->stat.curpos += sz;
if (up->stat.curpos == up->stat.curlen)
-@@ -568,7 +568,7 @@ rsync_sender(struct sess *sess, int fdin,
+@@ -569,7 +569,7 @@ rsync_sender(struct sess *sess, int fdin,
assert(pfd[2].fd == -1);
assert(wbufsz - wbufpos);
ssz = write(fdout,
- wbuf + wbufpos, wbufsz - wbufpos);
+ (char *)wbuf + wbufpos, wbufsz - wbufpos);
- if (ssz < 0) {
- ERR(sess, "write");
+ if (ssz == -1) {
+ ERR("write");
goto out;
-diff --git a/usr.bin/rsync/uploader.c b/usr.bin/rsync/uploader.c
-index 70aab10e6f5..c6e5ebf4d7a 100644
---- a/usr.bin/rsync/uploader.c
-+++ b/usr.bin/rsync/uploader.c
-@@ -158,8 +158,8 @@ init_blk(struct blk *p, const struct blkset *set, off_t offs,
- p->len = idx < set->blksz - 1 ? set->len : set->rem;
- p->offs = offs;
-
-- p->chksum_short = hash_fast(map + offs, p->len);
-- hash_slow(map + offs, p->len, p->chksum_long, sess);
-+ p->chksum_short = hash_fast((char *)map + offs, p->len);
-+ hash_slow((char *)map + offs, p->len, p->chksum_long, sess);
- }
-
- /*
--
-2.22.0
+2.23.0