commit d33a45e
Michael Forney
·
2026-04-03 00:19:10 +0000 UTC
parent 9f69eb2
openbsd: Various portability fixes
4 files changed,
+197,
-5
1@@ -1,17 +1,17 @@
2-From 3823d88a12d7c95de2d4b68796b5faa7f550caed Mon Sep 17 00:00:00 2001
3+From 2dc242877741913abaf8685c616406812d507e17 Mon Sep 17 00:00:00 2001
4 From: Michael Forney <mforney@mforney.org>
5 Date: Sat, 15 Jun 2019 20:06:13 -0700
6 Subject: [PATCH] rsync: Avoid pointer arithmetic on `void *`
7
8 ---
9- usr.bin/rsync/blocks.c | 8 ++++----
10+ usr.bin/rsync/blocks.c | 12 ++++++------
11 usr.bin/rsync/downloader.c | 2 +-
12 usr.bin/rsync/io.c | 12 ++++++------
13 usr.bin/rsync/sender.c | 5 +++--
14- 4 files changed, 14 insertions(+), 13 deletions(-)
15+ 4 files changed, 16 insertions(+), 15 deletions(-)
16
17 diff --git a/usr.bin/rsync/blocks.c b/usr.bin/rsync/blocks.c
18-index d1d9b19c31e..8f4bcb532e1 100644
19+index d1d9b19c31e..9aca8c217a6 100644
20 --- a/usr.bin/rsync/blocks.c
21 +++ b/usr.bin/rsync/blocks.c
22 @@ -163,7 +163,7 @@ blk_find(struct sess *sess, struct blkstat *st,
23@@ -50,6 +50,24 @@ index d1d9b19c31e..8f4bcb532e1 100644
24 st->s1 -= map[0];
25 st->s2 -= osz * map[0];
26
27+@@ -287,7 +287,7 @@ blk_match(struct sess *sess, const struct blkset *blks,
28+ blk->len, blk->idx);
29+ tok = -(blk->idx + 1);
30+
31+- hash_file_buf(&st->ctx, st->map + last, sz + blk->len);
32++ hash_file_buf(&st->ctx, (char *)st->map + last, sz + blk->len);
33+
34+ /*
35+ * Write the data we have, then follow it with
36+@@ -312,7 +312,7 @@ blk_match(struct sess *sess, const struct blkset *blks,
37+ LOG4("%s: flushing %s %jd B", path,
38+ last == 0 ? "whole" : "remaining", (intmax_t)sz);
39+
40+- hash_file_buf(&st->ctx, st->map + last, sz);
41++ hash_file_buf(&st->ctx, (char *)st->map + last, sz);
42+
43+ st->total += sz;
44+ st->dirty += sz;
45 diff --git a/usr.bin/rsync/downloader.c b/usr.bin/rsync/downloader.c
46 index cab6eb23f9f..07ec334f6b4 100644
47 --- a/usr.bin/rsync/downloader.c
1@@ -0,0 +1,148 @@
2+From d74af6c05b11f5d000f0a4aae3c287b6d4e2829f Mon Sep 17 00:00:00 2001
3+From: Michael Forney <mforney@mforney.org>
4+Date: Thu, 2 Apr 2026 17:02:47 -0700
5+Subject: [PATCH] Explicitly cast arguments to functions expecting char pointer
6+ with other sign
7+
8+---
9+ usr.bin/diff/diffreg.c | 10 +++++-----
10+ usr.bin/nc/socks.c | 30 +++++++++++++++---------------
11+ usr.sbin/acme-client/acctproc.c | 3 ++-
12+ 3 files changed, 22 insertions(+), 21 deletions(-)
13+
14+diff --git a/usr.bin/diff/diffreg.c b/usr.bin/diff/diffreg.c
15+index 3470f54c337..c36765a44c8 100644
16+--- a/usr.bin/diff/diffreg.c
17++++ b/usr.bin/diff/diffreg.c
18+@@ -1269,19 +1269,19 @@ match_function(const long *f, int pos, FILE *fp)
19+ nc = fread(buf, 1, nc, fp);
20+ if (nc > 0) {
21+ buf[nc] = '\0';
22+- buf[strcspn(buf, "\n")] = '\0';
23++ buf[strcspn((char *)buf, "\n")] = '\0';
24+ if (isalpha(buf[0]) || buf[0] == '_' || buf[0] == '$') {
25+- if (begins_with(buf, "private:")) {
26++ if (begins_with((char *)buf, "private:")) {
27+ if (!state)
28+ state = " (private)";
29+- } else if (begins_with(buf, "protected:")) {
30++ } else if (begins_with((char *)buf, "protected:")) {
31+ if (!state)
32+ state = " (protected)";
33+- } else if (begins_with(buf, "public:")) {
34++ } else if (begins_with((char *)buf, "public:")) {
35+ if (!state)
36+ state = " (public)";
37+ } else {
38+- strlcpy(lastbuf, buf, sizeof lastbuf);
39++ strlcpy(lastbuf, (char *)buf, sizeof lastbuf);
40+ if (state)
41+ strlcat(lastbuf, state,
42+ sizeof lastbuf);
43+diff --git a/usr.bin/nc/socks.c b/usr.bin/nc/socks.c
44+index 1f1fb96e2af..37a18f191f2 100644
45+--- a/usr.bin/nc/socks.c
46++++ b/usr.bin/nc/socks.c
47+@@ -88,7 +88,7 @@ decode_addrport(const char *h, const char *p, struct sockaddr *addr,
48+ }
49+
50+ static int
51+-proxy_read_line(int fd, char *buf, size_t bufsz)
52++proxy_read_line(int fd, unsigned char *buf, size_t bufsz)
53+ {
54+ size_t off;
55+
56+@@ -315,7 +315,7 @@ socks_connect(const char *host, const char *port,
57+ wlen = 9;
58+ if (socksv == 44) {
59+ /* SOCKS4A has nul-terminated hostname after user */
60+- if (strlcpy(buf + 9, host,
61++ if (strlcpy((char *)buf + 9, host,
62+ sizeof(buf) - 9) >= sizeof(buf) - 9)
63+ errx(1, "hostname too big");
64+ wlen = 9 + strlen(host) + 1;
65+@@ -340,17 +340,17 @@ socks_connect(const char *host, const char *port,
66+
67+ /* Try to be sane about numeric IPv6 addresses */
68+ if (strchr(host, ':') != NULL) {
69+- r = snprintf(buf, sizeof(buf),
70++ r = snprintf((char *)buf, sizeof(buf),
71+ "CONNECT [%s]:%d HTTP/1.0\r\n",
72+ host, ntohs(serverport));
73+ } else {
74+- r = snprintf(buf, sizeof(buf),
75++ r = snprintf((char *)buf, sizeof(buf),
76+ "CONNECT %s:%d HTTP/1.0\r\n",
77+ host, ntohs(serverport));
78+ }
79+ if (r < 0 || (size_t)r >= sizeof(buf))
80+ errx(1, "hostname too long");
81+- r = strlen(buf);
82++ r = strlen((char *)buf);
83+
84+ cnt = atomicio(vwrite, proxyfd, buf, r);
85+ if (cnt != r)
86+@@ -362,18 +362,18 @@ socks_connect(const char *host, const char *port,
87+
88+ getproxypass(proxyuser, proxyhost,
89+ proxypass, sizeof proxypass);
90+- r = snprintf(buf, sizeof(buf), "%s:%s",
91++ r = snprintf((char *)buf, sizeof(buf), "%s:%s",
92+ proxyuser, proxypass);
93+ explicit_bzero(proxypass, sizeof proxypass);
94+ if (r == -1 || (size_t)r >= sizeof(buf) ||
95+- b64_ntop(buf, strlen(buf), resp,
96++ b64_ntop(buf, strlen((char *)buf), resp,
97+ sizeof(resp)) == -1)
98+ errx(1, "Proxy username/password too long");
99+- r = snprintf(buf, sizeof(buf), "Proxy-Authorization: "
100+- "Basic %s\r\n", resp);
101++ r = snprintf((char *)buf, sizeof(buf),
102++ "Proxy-Authorization: Basic %s\r\n", resp);
103+ if (r < 0 || (size_t)r >= sizeof(buf))
104+ errx(1, "Proxy auth response too long");
105+- r = strlen(buf);
106++ r = strlen((char *)buf);
107+ if ((cnt = atomicio(vwrite, proxyfd, buf, r)) != r)
108+ err(1, "write failed (%zu/%d)", cnt, r);
109+ explicit_bzero(proxypass, sizeof proxypass);
110+@@ -387,17 +387,17 @@ socks_connect(const char *host, const char *port,
111+ /* Read status reply */
112+ proxy_read_line(proxyfd, buf, sizeof(buf));
113+ if (proxyuser != NULL &&
114+- (strncmp(buf, "HTTP/1.0 407 ", 13) == 0 ||
115+- strncmp(buf, "HTTP/1.1 407 ", 13) == 0)) {
116++ (strncmp((char *)buf, "HTTP/1.0 407 ", 13) == 0 ||
117++ strncmp((char *)buf, "HTTP/1.1 407 ", 13) == 0)) {
118+ if (authretry > 1) {
119+ fprintf(stderr, "Proxy authentication "
120+ "failed\n");
121+ }
122+ close(proxyfd);
123+ goto again;
124+- } else if (strncmp(buf, "HTTP/1.0 200 ", 13) != 0 &&
125+- strncmp(buf, "HTTP/1.1 200 ", 13) != 0)
126+- errx(1, "Proxy error: \"%s\"", buf);
127++ } else if (strncmp((char *)buf, "HTTP/1.0 200 ", 13) != 0 &&
128++ strncmp((char *)buf, "HTTP/1.1 200 ", 13) != 0)
129++ errx(1, "Proxy error: \"%s\"", (char *)buf);
130+
131+ /* Headers continue until we hit an empty line */
132+ for (r = 0; r < HTTP_MAXHDRS; r++) {
133+diff --git a/usr.sbin/acme-client/acctproc.c b/usr.sbin/acme-client/acctproc.c
134+index 8d66dac49d9..6bc647c6009 100644
135+--- a/usr.sbin/acme-client/acctproc.c
136++++ b/usr.sbin/acme-client/acctproc.c
137+@@ -215,7 +215,8 @@ op_sign(int fd, struct key *key, enum acctop op)
138+
139+ /* Base64-encode the payload. */
140+
141+- if ((pay64 = base64buf_url(pay, strlen(pay))) == NULL) {
142++ if ((pay64 = base64buf_url((unsigned char *)pay,
143++ strlen(pay))) == NULL) {
144+ warnx("base64buf_url");
145+ goto out;
146+ }
147+--
148+2.49.0
149+
1@@ -0,0 +1,26 @@
2+From 5b997ce94b67bfd5c3f1a34c33fb14b11a8b5c81 Mon Sep 17 00:00:00 2001
3+From: Michael Forney <mforney@mforney.org>
4+Date: Thu, 2 Apr 2026 17:17:27 -0700
5+Subject: [PATCH] fts: Use prototype in declaration of fts_compar
6+
7+In C23, empty parenthesis indications a function taking no arguments.
8+---
9+ include/fts.h | 2 +-
10+ 1 file changed, 1 insertion(+), 1 deletion(-)
11+
12+diff --git a/include/fts.h b/include/fts.h
13+index a5b3aff91e7..ef25e88d298 100644
14+--- a/include/fts.h
15++++ b/include/fts.h
16+@@ -46,7 +46,7 @@ typedef struct {
17+ int fts_rfd; /* fd for root */
18+ size_t fts_pathlen; /* sizeof(path) */
19+ int fts_nitems; /* elements in the sort array */
20+- int (*fts_compar)(); /* compare function */
21++ int (*fts_compar)(const void *, const void *); /* compare function */
22+
23+ #define FTS_COMFOLLOW 0x0001 /* follow command line symlinks */
24+ #define FTS_LOGICAL 0x0002 /* logical walk */
25+--
26+2.49.0
27+
+1,
-1
1@@ -1 +1 @@
2-7.8 r0
3+7.8 r1