GNU bug report logs - #77325
Crash in Fjson_parse_buffer: ZV changes underneath it?

Previous Next

Package: emacs;

Reported by: Daniel Colascione <dancol <at> dancol.org>

Date: Fri, 28 Mar 2025 01:08:02 UTC

Severity: normal

Full log


Message #47 received at 77325 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Pip Cet <pipcet <at> protonmail.com>
Cc: dancol <at> dancol.org, 77325 <at> debbugs.gnu.org
Subject: Re: bug#77325: Crash in Fjson_parse_buffer: ZV changes underneath it?
Date: Sun, 30 Mar 2025 14:45:20 +0300
> Date: Sun, 30 Mar 2025 10:40:42 +0000
> From: Pip Cet <pipcet <at> protonmail.com>
> Cc: dancol <at> dancol.org, 77325 <at> debbugs.gnu.org
> 
> "Eli Zaretskii" <eliz <at> gnu.org> writes:
> 
> > I'd prefer the secondary_* values to be set NULL explicitly, otherwise
> > it is hard to understand what the code does without looking deep into
> > the subroutines of json_parse.
> 
> Sorry, it took me a while.  I was surprised by how tricky this is, and I
> admit I was confused briefly because ZV == GPT doesn't make ZV_ADDR ==
> GPT_ADDR.  I can see that most places in the code manipulate byte
> positions, not pointers, and I think I understand the reason now :-)

Yes, it's a bit tricky.

> >From dd30d60a7992da0cef4e09a8a7e8989249dab4f1 Mon Sep 17 00:00:00 2001
> From: Pip Cet <pipcet <at> protonmail.com>
> Subject: [PATCH] Respect narrowed buffers when parsing JSON (bug#77325)
> 
> * src/json.c (Fjson_insert): Simplify 'memcpy' argument.
> (Fjson_parse_buffer): Only read to ZV, not all the way to Z.
> * test/src/json-tests.el (with-all-gap-positions-in-temp-buffer):
> New macro.
> (json-parse-buffer/restricted): New test.

Thanks, LGTM.




This bug report was last modified 80 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.