From 6eb34c506665faba225e7fbf806ac5ac0ff3cd0f Mon Sep 17 00:00:00 2001 From: "James W. Mills" Date: Sun, 1 Mar 2026 09:52:20 -0600 Subject: [PATCH] Fix ASCII character range check for UTF-8 JSON specifies that ASCII control characters 0x00 through 0x1F must not appear in the string. This patch adds the lower bounds in order to handle UTF-8 characters whose individual bytes might be negative (like the "registered" symbol 0xc2 0xae). Co-authored-by: Dave Mulford --- src/pulsecore/json.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pulsecore/json.c b/src/pulsecore/json.c index 0f204b051..ca6badb69 100644 --- a/src/pulsecore/json.c +++ b/src/pulsecore/json.c @@ -150,7 +150,7 @@ static const char* parse_string(const char *str, pa_json_object *obj) { if (*str != '\\') { /* JSON specifies that ASCII control characters 0x00 through 0x1F * must not appear in the string. */ - if (*str < 0x20) { + if (*str >= 0x00 && *str < 0x20) { pa_log("Invalid ASCII character: 0x%x", (unsigned int) *str); goto error; } @@ -763,7 +763,7 @@ static char *pa_json_escape(const char *p) { *output++ = 't'; break; default: - if (*s < 0x20 || *s == 0x7F) { + if ((*s >= 0x00 && *s < 0x20) || *s == 0x7F) { pa_log("Invalid ASCII character: 0x%x", (unsigned int) *s); pa_xfree(out_string); return NULL;