Subject: bug#42113: 28.0.50; Segmentation fault in json-parse-file

From: Eli Zaretskii <[email-masked]>
Date: Mon, 29 Jun 2020 17:56:26 +0300

> From: Philipp Stephani <[email-masked]>
> Date: Mon, 29 Jun 2020 12:07:33 +0200
> Cc: [email-masked], Erik Hetzner <[email-masked]>, [email-masked]
> 
> > > The JSON functions are missing CHECK_STRING in several places where
> > > json_encode is called.
> >
> > In this specific case I think the test is there, but it is done a bit too late.  The call to check_string_without_embedded_nuls should be moved before json_encode.
> 
> Is that always guaranteed to be correct though? Is there a guarantee
> that encoding can never produce null bytes that weren't already
> present in the input?

It is true that you could in principle write a coding-system that
would produce null bytes (although it wouldn't be very useful).  But
in this case we are not talking about any  arbitrary coding-system, we
are talking specifically about UTF-8.