0041-Explicitly-cast-arguments-to-functions-expecting-cha.patch (5368B)
1 From d74af6c05b11f5d000f0a4aae3c287b6d4e2829f Mon Sep 17 00:00:00 2001 2 From: Michael Forney <mforney@mforney.org> 3 Date: Thu, 2 Apr 2026 17:02:47 -0700 4 Subject: [PATCH] Explicitly cast arguments to functions expecting char pointer 5 with other sign 6 7 --- 8 usr.bin/diff/diffreg.c | 10 +++++----- 9 usr.bin/nc/socks.c | 30 +++++++++++++++--------------- 10 usr.sbin/acme-client/acctproc.c | 3 ++- 11 3 files changed, 22 insertions(+), 21 deletions(-) 12 13 diff --git a/usr.bin/diff/diffreg.c b/usr.bin/diff/diffreg.c 14 index 3470f54c337..c36765a44c8 100644 15 --- a/usr.bin/diff/diffreg.c 16 +++ b/usr.bin/diff/diffreg.c 17 @@ -1269,19 +1269,19 @@ match_function(const long *f, int pos, FILE *fp) 18 nc = fread(buf, 1, nc, fp); 19 if (nc > 0) { 20 buf[nc] = '\0'; 21 - buf[strcspn(buf, "\n")] = '\0'; 22 + buf[strcspn((char *)buf, "\n")] = '\0'; 23 if (isalpha(buf[0]) || buf[0] == '_' || buf[0] == '$') { 24 - if (begins_with(buf, "private:")) { 25 + if (begins_with((char *)buf, "private:")) { 26 if (!state) 27 state = " (private)"; 28 - } else if (begins_with(buf, "protected:")) { 29 + } else if (begins_with((char *)buf, "protected:")) { 30 if (!state) 31 state = " (protected)"; 32 - } else if (begins_with(buf, "public:")) { 33 + } else if (begins_with((char *)buf, "public:")) { 34 if (!state) 35 state = " (public)"; 36 } else { 37 - strlcpy(lastbuf, buf, sizeof lastbuf); 38 + strlcpy(lastbuf, (char *)buf, sizeof lastbuf); 39 if (state) 40 strlcat(lastbuf, state, 41 sizeof lastbuf); 42 diff --git a/usr.bin/nc/socks.c b/usr.bin/nc/socks.c 43 index 1f1fb96e2af..37a18f191f2 100644 44 --- a/usr.bin/nc/socks.c 45 +++ b/usr.bin/nc/socks.c 46 @@ -88,7 +88,7 @@ decode_addrport(const char *h, const char *p, struct sockaddr *addr, 47 } 48 49 static int 50 -proxy_read_line(int fd, char *buf, size_t bufsz) 51 +proxy_read_line(int fd, unsigned char *buf, size_t bufsz) 52 { 53 size_t off; 54 55 @@ -315,7 +315,7 @@ socks_connect(const char *host, const char *port, 56 wlen = 9; 57 if (socksv == 44) { 58 /* SOCKS4A has nul-terminated hostname after user */ 59 - if (strlcpy(buf + 9, host, 60 + if (strlcpy((char *)buf + 9, host, 61 sizeof(buf) - 9) >= sizeof(buf) - 9) 62 errx(1, "hostname too big"); 63 wlen = 9 + strlen(host) + 1; 64 @@ -340,17 +340,17 @@ socks_connect(const char *host, const char *port, 65 66 /* Try to be sane about numeric IPv6 addresses */ 67 if (strchr(host, ':') != NULL) { 68 - r = snprintf(buf, sizeof(buf), 69 + r = snprintf((char *)buf, sizeof(buf), 70 "CONNECT [%s]:%d HTTP/1.0\r\n", 71 host, ntohs(serverport)); 72 } else { 73 - r = snprintf(buf, sizeof(buf), 74 + r = snprintf((char *)buf, sizeof(buf), 75 "CONNECT %s:%d HTTP/1.0\r\n", 76 host, ntohs(serverport)); 77 } 78 if (r < 0 || (size_t)r >= sizeof(buf)) 79 errx(1, "hostname too long"); 80 - r = strlen(buf); 81 + r = strlen((char *)buf); 82 83 cnt = atomicio(vwrite, proxyfd, buf, r); 84 if (cnt != r) 85 @@ -362,18 +362,18 @@ socks_connect(const char *host, const char *port, 86 87 getproxypass(proxyuser, proxyhost, 88 proxypass, sizeof proxypass); 89 - r = snprintf(buf, sizeof(buf), "%s:%s", 90 + r = snprintf((char *)buf, sizeof(buf), "%s:%s", 91 proxyuser, proxypass); 92 explicit_bzero(proxypass, sizeof proxypass); 93 if (r == -1 || (size_t)r >= sizeof(buf) || 94 - b64_ntop(buf, strlen(buf), resp, 95 + b64_ntop(buf, strlen((char *)buf), resp, 96 sizeof(resp)) == -1) 97 errx(1, "Proxy username/password too long"); 98 - r = snprintf(buf, sizeof(buf), "Proxy-Authorization: " 99 - "Basic %s\r\n", resp); 100 + r = snprintf((char *)buf, sizeof(buf), 101 + "Proxy-Authorization: Basic %s\r\n", resp); 102 if (r < 0 || (size_t)r >= sizeof(buf)) 103 errx(1, "Proxy auth response too long"); 104 - r = strlen(buf); 105 + r = strlen((char *)buf); 106 if ((cnt = atomicio(vwrite, proxyfd, buf, r)) != r) 107 err(1, "write failed (%zu/%d)", cnt, r); 108 explicit_bzero(proxypass, sizeof proxypass); 109 @@ -387,17 +387,17 @@ socks_connect(const char *host, const char *port, 110 /* Read status reply */ 111 proxy_read_line(proxyfd, buf, sizeof(buf)); 112 if (proxyuser != NULL && 113 - (strncmp(buf, "HTTP/1.0 407 ", 13) == 0 || 114 - strncmp(buf, "HTTP/1.1 407 ", 13) == 0)) { 115 + (strncmp((char *)buf, "HTTP/1.0 407 ", 13) == 0 || 116 + strncmp((char *)buf, "HTTP/1.1 407 ", 13) == 0)) { 117 if (authretry > 1) { 118 fprintf(stderr, "Proxy authentication " 119 "failed\n"); 120 } 121 close(proxyfd); 122 goto again; 123 - } else if (strncmp(buf, "HTTP/1.0 200 ", 13) != 0 && 124 - strncmp(buf, "HTTP/1.1 200 ", 13) != 0) 125 - errx(1, "Proxy error: \"%s\"", buf); 126 + } else if (strncmp((char *)buf, "HTTP/1.0 200 ", 13) != 0 && 127 + strncmp((char *)buf, "HTTP/1.1 200 ", 13) != 0) 128 + errx(1, "Proxy error: \"%s\"", (char *)buf); 129 130 /* Headers continue until we hit an empty line */ 131 for (r = 0; r < HTTP_MAXHDRS; r++) { 132 diff --git a/usr.sbin/acme-client/acctproc.c b/usr.sbin/acme-client/acctproc.c 133 index 8d66dac49d9..6bc647c6009 100644 134 --- a/usr.sbin/acme-client/acctproc.c 135 +++ b/usr.sbin/acme-client/acctproc.c 136 @@ -215,7 +215,8 @@ op_sign(int fd, struct key *key, enum acctop op) 137 138 /* Base64-encode the payload. */ 139 140 - if ((pay64 = base64buf_url(pay, strlen(pay))) == NULL) { 141 + if ((pay64 = base64buf_url((unsigned char *)pay, 142 + strlen(pay))) == NULL) { 143 warnx("base64buf_url"); 144 goto out; 145 } 146 -- 147 2.49.0 148