aboutsummaryrefslogtreecommitdiff
path: root/patches/0028-rsync-Avoid-pointer-arithmetic-on-void.patch
blob: 885ce499e2451262f836406260c912889a70790e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
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     |  8 ++++----
 usr.bin/rsync/downloader.c |  2 +-
 usr.bin/rsync/io.c         | 12 ++++++------
 usr.bin/rsync/sender.c     |  4 ++--
 4 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/usr.bin/rsync/blocks.c b/usr.bin/rsync/blocks.c
index 4f21a41833d..242590e5bae 100644
--- a/usr.bin/rsync/blocks.c
+++ b/usr.bin/rsync/blocks.c
@@ -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[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(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 9ddb8600a73..36b086f74c8 100644
--- a/usr.bin/rsync/downloader.c
+++ b/usr.bin/rsync/downloader.c
@@ -495,7 +495,7 @@ again:
 		sz = tok == p->blk.blksz - 1 ? p->blk.rem : p->blk.len;
 		assert(sz);
 		assert(p->map != MAP_FAILED);
-		buf = p->map + (tok * p->blk.len);
+		buf = (char *)p->map + (tok * p->blk.len);
 
 		/*
 		 * Now we read from our block.
diff --git a/usr.bin/rsync/io.c b/usr.bin/rsync/io.c
index 8d113d6d013..181458ced08 100644
--- a/usr.bin/rsync/io.c
+++ b/usr.bin/rsync/io.c
@@ -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;
+		buf = (char *)buf + wsz;
 		sz -= wsz;
 	}
 
@@ -156,7 +156,7 @@ io_write_buf(struct sess *sess, int fd, const void *buf, size_t sz)
 		}
 		sess->total_write += wsz;
 		sz -= wsz;
-		buf += wsz;
+		buf = (char *)buf + wsz;
 	}
 
 	return 1;
@@ -250,7 +250,7 @@ io_read_blocking(int fd, void *buf, size_t sz)
 			ERRX("io_read_nonblocking: short read");
 			return 0;
 		}
-		buf += rsz;
+		buf = (char *)buf + rsz;
 		sz -= rsz;
 	}
 
@@ -367,7 +367,7 @@ io_read_buf(struct sess *sess, int fd, void *buf, size_t sz)
 			}
 			sz -= rsz;
 			sess->mplex_read_remain -= rsz;
-			buf += rsz;
+			buf = (char *)buf + rsz;
 			sess->total_read += rsz;
 			continue;
 		}
@@ -463,7 +463,7 @@ io_buffer_buf(void *buf, size_t *bufpos, size_t buflen, const void *val,
 {
 
 	assert(*bufpos + valsz <= buflen);
-	memcpy(buf + *bufpos, val, valsz);
+	memcpy((char *)buf + *bufpos, val, valsz);
 	*bufpos += valsz;
 }
 
@@ -661,7 +661,7 @@ io_unbuffer_buf(const void *buf, size_t *bufpos, size_t bufsz, void *val,
 {
 
 	assert(*bufpos + valsz <= bufsz);
-	memcpy(val, buf + *bufpos, valsz);
+	memcpy(val, (char *)buf + *bufpos, valsz);
 	*bufpos += valsz;
 }
 
diff --git a/usr.bin/rsync/sender.c b/usr.bin/rsync/sender.c
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,
 			return 0;
 		}
 		io_lowbuffer_buf(sess, *wb, &pos, *wbsz,
-			up->stat.map + up->stat.curpos, sz);
+			(char *)up->stat.map + up->stat.curpos, sz);
 
 		up->stat.curpos += sz;
 		if (up->stat.curpos == up->stat.curlen)
@@ -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 == -1) {
 				ERR("write");
 				goto out;
-- 
2.23.0