]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
client/json: escape control character 0x1F
authorVincent Bernat <vincent@bernat.ch>
Sat, 9 May 2026 12:40:12 +0000 (14:40 +0200)
committerVincent Bernat <vincent@bernat.ch>
Sat, 9 May 2026 13:26:12 +0000 (15:26 +0200)
The off-by-one in the boundary check let byte 0x1F (US) be emitted
literally inside JSON strings, which is invalid per RFC 8259.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
src/client/json_writer.c

index b0c616d303f9b5a3ff9f91e2f92b200cb80d77f5..38395536a098aa1ce5742a8077c3d89030dff3a1 100644 (file)
@@ -138,8 +138,8 @@ json_string_dump(FILE *fh, const char *s)
                                 * replacement character */
                                fprintf(fh, "\\uFFFD");
                                s++;
-                       } else if (c < 0x1f) {
-                               /* 7-bit ASCII character */
+                       } else if (c <= 0x1f) {
+                               /* C0 control character */
                                fprintf(fh, "\\u%04X", c);
                                s++;
                        } else {