logo

oasis

Own branch of Oasis Linux (upstream: <https://git.sr.ht/~mcf/oasis/>) git clone https://anongit.hacktivis.me/git/oasis.git

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