Fix ujson bugs
Get series with b4
b4 am [email protected] change-id 20260925-fix_core_lib_deepseek-2ba9018c7588Versions newest first
- v2 Latest15 patches 2 repliesIn review
- v115 patches 15 repliesSuperseded
Changes in v2 from the cover letter · 20 lines
- ujson: reader: Prevent infinite loop on EOF: fail load on premature
EOF instead of accepting truncated file.
- ujson: reader: Return UTF-8 length when !str: split out UTF-8 length calculation when !str into separate commit before surrogate handling.
- ujson: reader: Combine UTF-16 surrogate pairs: reorder checks to
inspect unpaired low surrogates first.
- ujson: reader: Check for signed integer overflow: assign negative
integers with -(long)val.
- ujson: writer: Check return value in esc_flush(): replace ESC_FLUSH
macro with esc_flush() helper function and check return values.
- ujson: reader: Do not increment depth on overflow: dropped from
series.
- ujson: reader: Parse escape sequences in object IDs: reset res->type
to UJSON_VOID on key parsing failure.
- ujson: reader: Reject files with zero size: reject zero-sized and
empty files in ujson_reader_load() instead of dynamic reallocation.
- ujson: writer: Set errno when a flush fails: distinguish ret == 0
with a dedicated error message and errno = EAGAIN.
- ujson: writer: Flush buffer before direct writes: move !buf_len
check into out_writer_file_write().
- Link to v1: https://lore.kernel.org/[email protected]
Patches in v2 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/15 | ujson: Fix 4-byte UTF-8 sequence decodinginclude/ | +3 | 2 replies | |
| 2/15 | ujson: writer: Fix OOB read on invalid UTF-8libs/ | +4 | 0 replies | |
| 3/15 | ujson: reader: Prevent infinite loop on EOFlibs/ | +5 | 0 replies | |
| 4/15 | ujson: writer: Fix open() return value checklibs/ | +1 | 0 replies | |
| 5/15 | ujson: reader: Return UTF-8 length when !strlibs/ | +1 | 0 replies | |
| 6/15 | ujson: reader: Combine UTF-16 surrogate pairslibs/ | +28 | 0 replies | |
| 7/15 | ujson: reader: Check for signed integer overflowlibs/ | +16 | 0 replies | |
| 8/15 | ujson: writer: Return error when newline() failslibs/ | +5 | 0 replies | |
| 9/15 | ujson: writer: Check return value in esc_flush()libs/ | +23 | 0 replies | |
| 10/15 | ujson: reader: Parse escape sequences in object IDslibs/ | +9 | 0 replies | |
| 11/15 | ujson: reader: Reject files with zero sizelibs/ | +5 | 0 replies | |
| 12/15 | ujson: reader: Reject \u0000 escape in stringslibs/ | +6 | 0 replies | |
| 13/15 | ujson: writer: Set errno when a flush failslibs/ | +8 | 0 replies | |
| 14/15 | ujson: writer: Advance buffer on short writelibs/ | +1 | 0 replies | |
| 15/15 | ujson: writer: Flush buffer before direct writeslibs/ | +11 | 0 replies |
Reviews trailers per patch
5 of 15 patches have a Reviewed-by or Acked-by.
| Patch | Cyril Hrubis |
|---|---|
| 1/15 | |
| 2/15 | R-b |
| 3/15 | |
| 4/15 | R-b |
| 5/15 | |
| 6/15 | |
| 7/15 | |
| 8/15 | R-b |
| 9/15 | |
| 10/15 | |
| 11/15 | |
| 12/15 | R-b |
| 13/15 | |
| 14/15 | R-b |
| 15/15 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [LTP] [PATCH v2 00/15] Fix ujson bugs
- fix 4-byte UTF-8 sequence decoding in ujson_utf8_next()
- fix out-of-bounds read on invalid UTF-8 in ujson_writer
- prevent infinite loop when read() returns 0 in ujson_reader
- fix inverted open() error check in ujson_writer_file_open()
- return UTF-8 length when calculating string size in ujson_reader
- combine UTF-16 surrogate pairs and reject lone surrogates
- check for signed integer overflow when parsing numbers
- fix error propagation when newline() fails in ujson_writer
- check output return values in esc_flush() helper
- unescape object IDs and reset type on error in ujson_reader
- reject empty and zero-sized files in ujson_reader_load()
- reject \u0000 escape sequences in string values
- set errno when a file flush fails in ujson_writer
- advance buffer pointer on short write in ujson_writer
- flush buffered data before direct writes in ujson_writer
---
Changes in v2:
- ujson: reader: Prevent infinite loop on EOF: fail load on premature
EOF instead of accepting truncated file.
- ujson: reader: Return UTF-8 length when !str: split out UTF-8 length calculation when !str into separate commit before surrogate handling.
- ujson: reader: Combine UTF-16 surrogate pairs: reorder checks to
inspect unpaired low surrogates first.
- ujson: reader: Check for signed integer overflow: assign negative
integers with -(long)val.
- ujson: writer: Check return value in esc_flush(): replace ESC_FLUSH
macro with esc_flush() helper function and check return values.
- ujson: reader: Do not increment depth on overflow: dropped from
series.
- ujson: reader: Parse escape sequences in object IDs: reset res->type
to UJSON_VOID on key parsing failure.
- ujson: reader: Reject files with zero size: reject zero-sized and
empty files in ujson_reader_load() instead of dynamic reallocation.
- ujson: writer: Set errno when a flush fails: distinguish ret == 0
with a dedicated error message and errno = EAGAIN.
- ujson: writer: Flush buffer before direct writes: move !buf_len
check into out_writer_file_write().
- Link to v1: https://lore.kernel.org/[email protected]
---
Andrea Cervesato (15):
ujson: Fix 4-byte UTF-8 sequence decoding
ujson: writer: Fix OOB read on invalid UTF-8
ujson: reader: Prevent infinite loop on EOF
ujson: writer: Fix open() return value check
ujson: reader: Return UTF-8 length when !str
ujson: reader: Combine UTF-16 surrogate pairs
ujson: reader: Check for signed integer overflow
ujson: writer: Return error when newline() fails
ujson: writer: Check return value in esc_flush()
ujson: reader: Parse escape sequences in object IDs
ujson: reader: Reject files with zero size
ujson: reader: Reject \u0000 escape in strings
ujson: writer: Set errno when a flush fails
ujson: writer: Advance buffer on short write
ujson: writer: Flush buffer before direct writes
include/ujson_utf.h | 6 +-- libs/ujson/ujson_reader.c | 101 ++++++++++++++++++++++++++++++++-------------- libs/ujson/ujson_writer.c | 75 ++++++++++++++++++++++++---------- 3 files changed, 126 insertions(+), 56 deletions(-)
---
base-commit: 07da37cf3dbda876b33ad820168a33b9deacbddb
change-id: 20260925-fix_core_lib_deepseek-2ba9018c7588
Best regards,
Signature · 5 lines
Andrea Cervesato <[email protected]> -- Mailing list info: https://lists.linux.it/listinfo/ltp