Re: [PATCH 1/3] sideband: mask control characters
From: Junio C Hamano <hidden>
Date: 2025-01-15 16:24:20
Andreas Schwab [off-list ref] writes:
On Jan 14 2025, Johannes Schindelin via GitGitGadget wrote:quoted
diff --git a/sideband.c b/sideband.c index 02805573fab..c0b1cb044a3 100644 --- a/sideband.c +++ b/sideband.c@@ -65,6 +65,19 @@ void list_config_color_sideband_slots(struct string_list *list, const char *pref list_config_item(list, prefix, keywords[i].keyword); } +static void strbuf_add_sanitized(struct strbuf *dest, const char *src, int n) +{ + strbuf_grow(dest, n); + for (; n && *src; src++, n--) { + if (!iscntrl(*src) || *src == '\t' || *src == '\n')The argument of iscntrl needs to be converted to unsigned char.
If this were system-provided one, you are absolutely correct. But I think this comes from sane-ctype.h:15:#undef iscntrl sane-ctype.h:40:#define iscntrl(x) (sane_istest(x,GIT_CNTRL)) and sane_istest() does the casting to uchar for us, so this may be OK (even if it may be a bit misleading).