Linux Test Project
 help / color / mirror / Atom feed
From: linuxtestproject.agent@gmail.com
To: Andrea Cervesato <andrea.cervesato@suse.de>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] ujson: Fix 4-byte UTF-8 sequence decoding
Date: Mon,  5 Oct 2026 18:06:25 +0000	[thread overview]
Message-ID: <20261005180626.5304-1-linuxtestproject.agent@gmail.com> (raw)
In-Reply-To: <20261005-fix_core_lib_deepseek-v1-3-fec334ce8e80@suse.com>

Hi Andrea,

On 5 October 2026, Andrea Cervesato wrote:
> ujson: Fix 4-byte UTF-8 sequence decoding

--- [PATCH 10/15] ---

> diff --git a/libs/ujson/ujson_reader.c b/libs/ujson/ujson_reader.c
> +	if (copy_str(buf, str, len))
> +		return 1;

Medium: For {"first":1,"bad\q":2}, ujson_obj_next() returns zero but leaves
res->type as UJSON_INT, id as "badst", and the previous integer value.
UJSON_OBJ_FOREACH therefore executes its body again with that stale value.
Set res->type to UJSON_VOID on ID-parsing errors in both obj_next() and
obj_next_filter().

--- [PATCH 11/15] ---

> diff --git a/libs/ujson/ujson_reader.c b/libs/ujson/ujson_reader.c
> +	capacity = len > 0 ? (size_t)len + 1 : 4096;

Medium: On 32-bit musl, where off_t is 64-bit, a 4 GiB - 1 byte file makes
capacity wrap to zero; doubling zero still yields zero, read(..., 0)
returns zero, and loading succeeds with an empty reader.
Reject lengths that cannot fit the allocation before narrowing to size_t,
and check the allocation additions and capacity doubling for overflow.

Verdict - Needs revision

Pre-existing issue exercised by patch 5:

> if (ujson_utf8_bytes(ucode) + 1 >= len - off) {

Medium: The new surrogate-pair path reaches this off-by-one check:
["\uD83D\uDE00"] fails with a five-byte output buffer even though the four
UTF-8 bytes and terminating NUL fit exactly.
Change >= to > so an exactly sufficient buffer is accepted.

---
Note:

The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.

Regards,
LTP AI Reviewer

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  parent reply	other threads:[~2026-10-05 18:06 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-05 13:25 [LTP] [PATCH 00/15] Fix ujson bugs Andrea Cervesato
2026-10-05 13:25 ` [LTP] [PATCH 01/15] ujson: Fix 4-byte UTF-8 sequence decoding Andrea Cervesato
2026-10-05 14:57   ` Cyril Hrubis
2026-10-05 13:25 ` [LTP] [PATCH 02/15] ujson: writer: Fix OOB read on invalid UTF-8 Andrea Cervesato
2026-10-05 15:04   ` Cyril Hrubis
2026-10-05 13:25 ` [LTP] [PATCH 03/15] ujson: reader: Prevent infinite loop on EOF Andrea Cervesato
2026-10-05 15:12   ` Cyril Hrubis
2026-10-05 18:06   ` linuxtestproject.agent [this message]
2026-10-05 13:25 ` [LTP] [PATCH 04/15] ujson: writer: Fix open() return value check Andrea Cervesato
2026-10-05 15:15   ` Cyril Hrubis
2026-10-05 13:25 ` [LTP] [PATCH 05/15] ujson: reader: Combine UTF-16 surrogate pairs Andrea Cervesato
2026-10-05 15:36   ` Cyril Hrubis
2026-10-05 13:25 ` [LTP] [PATCH 06/15] ujson: reader: Check for signed integer overflow Andrea Cervesato
2026-10-09 11:59   ` Cyril Hrubis
2026-10-05 13:25 ` [LTP] [PATCH 07/15] ujson: writer: Return error when newline() fails Andrea Cervesato
2026-10-09 13:44   ` Cyril Hrubis
2026-10-05 13:25 ` [LTP] [PATCH 08/15] ujson: writer: Check return value in ESC_FLUSH Andrea Cervesato
2026-10-09 14:01   ` Cyril Hrubis
2026-10-05 13:25 ` [LTP] [PATCH 09/15] ujson: reader: Do not increment depth on overflow Andrea Cervesato
2026-10-09 14:15   ` Cyril Hrubis
2026-10-05 13:25 ` [LTP] [PATCH 10/15] ujson: reader: Parse escape sequences in object IDs Andrea Cervesato
2026-10-05 13:25 ` [LTP] [PATCH 11/15] ujson: reader: Support files with zero lseek size Andrea Cervesato
2026-10-09 15:21   ` Cyril Hrubis
2026-10-05 13:25 ` [LTP] [PATCH 12/15] ujson: reader: Reject \u0000 escape in strings Andrea Cervesato
2026-10-09 15:24   ` Cyril Hrubis
2026-10-05 13:25 ` [LTP] [PATCH 13/15] ujson: writer: Set errno when a flush fails Andrea Cervesato
2026-10-09 15:46   ` Cyril Hrubis
2026-10-05 13:25 ` [LTP] [PATCH 14/15] ujson: writer: Advance buffer on short write Andrea Cervesato
2026-10-09 15:52   ` Cyril Hrubis
2026-10-05 13:25 ` [LTP] [PATCH 15/15] ujson: writer: Flush buffer before direct writes Andrea Cervesato
2026-10-09 16:05   ` Cyril Hrubis
  -- strict thread matches above, loose matches on Subject: below --
2026-10-13 12:01 [LTP] [PATCH v2 01/15] ujson: Fix 4-byte UTF-8 sequence decoding Andrea Cervesato
2026-10-13 15:42 ` [LTP] " linuxtestproject.agent

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261005180626.5304-1-linuxtestproject.agent@gmail.com \
    --to=linuxtestproject.agent@gmail.com \
    --cc=andrea.cervesato@suse.de \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox