http: drop const to fix strstr() warning

In redact_sensitive_header(), a C23 implementation of libc will complain that strstr() assigns the result from "const char *cookie" to "char *semicolon". Ultimately the memory is writable. We're fed a strbuf, generate a const pointer "sensitive_header" within it using skip_iprefix(), and then assign the result to "cookie". So we can solve this by dropping the const from "cookie" and "sensitive_header". However, this runs afoul of skip_iprefix(), which wants a "const char **" for its out-parameter. We can solve that by teaching skip_iprefix() the same "make sure out is at least as const as in" magic that we recently taught to skip_prefix(). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Apr 2, 2026 at 00:15 UTC 8a0566b42b133b73423c801a7ab6f356de69f51a
2 files changed +6 -4
git-compat-util.h
+4 -2
@@ -902,8 +902,10 @@ static inline size_t xsize_t(off_t len)
902 * is done via tolower(), so it is strictly ASCII (no multi-byte characters or
903 * locale-specific conversions).
904 */
905 -static inline bool skip_iprefix(const char *str, const char *prefix,
906 - const char **out)
905 +#define skip_iprefix(str, prefix, out) \
906 + skip_iprefix_impl((str), (prefix), CONST_OUTPARAM((str), (out)))
907 +static inline bool skip_iprefix_impl(const char *str, const char *prefix,
908 + const char **out)
909 {
910 do {
911 if (!*prefix) {
http.c
+2 -2
@@ -726,7 +726,7 @@ static int has_proxy_cert_password(void)
726 static int redact_sensitive_header(struct strbuf *header, size_t offset)
727 {
728 int ret = 0;
729 - const char *sensitive_header;
729 + char *sensitive_header;
730
731 if (trace_curl_redact &&
732 (skip_iprefix(header->buf + offset, "Authorization:", &sensitive_header) ||
@@ -743,7 +743,7 @@ static int redact_sensitive_header(struct strbuf *header, size_t offset)
743 } else if (trace_curl_redact &&
744 skip_iprefix(header->buf + offset, "Cookie:", &sensitive_header)) {
745 struct strbuf redacted_header = STRBUF_INIT;
746 - const char *cookie;
746 + char *cookie;
747
748 while (isspace(*sensitive_header))
749 sensitive_header++;