9front - general discussion about 9front
 help / color / mirror / Atom feed
* [9front] [PATCH] libjson: make sure string contains only a single JSON value
@ 2023-08-07 15:29 Kristo
  2023-08-07 22:16 ` ori
  2023-09-18 12:59 ` ori
  0 siblings, 2 replies; 5+ messages in thread
From: Kristo @ 2023-08-07 15:29 UTC (permalink / raw)
  To: 9front

diff bf645afaac246967b9590ae7463f243c11d97480 uncommitted
--- a/sys/src/libjson/json.c
+++ b/sys/src/libjson/json.c
@@ -328,6 +328,13 @@

 	j = jsonobj(&l);
 	free(l.buf);
+
+	if(peeknonspace(&l) != 0){
+		jsonfree(j);
+		werrstr("json: unexpected trailing data");
+		return nil;
+	}
+
 	return j;
 }

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [9front] [PATCH] libjson: make sure string contains only a single JSON value
  2023-08-07 15:29 [9front] [PATCH] libjson: make sure string contains only a single JSON value Kristo
@ 2023-08-07 22:16 ` ori
  2023-08-08 14:44   ` [9front] " Kristo
  2023-09-18 12:59 ` ori
  1 sibling, 1 reply; 5+ messages in thread
From: ori @ 2023-08-07 22:16 UTC (permalink / raw)
  To: 9front

Quoth Kristo <kristo.ilmari@gmail.com>:
> diff bf645afaac246967b9590ae7463f243c11d97480 uncommitted
> --- a/sys/src/libjson/json.c
> +++ b /sys/src/libjson/json.c:328
> @@ -328,6 +328,13 @@
> 
>  	j = jsonobj(&l);
>  	free(l.buf);
> +
> +	if(peeknonspace(&l) != 0){

does this use the `l.buf` that we free one line up?

> +		jsonfree(j);
> +		werrstr("json: unexpected trailing data");
> +		return nil;
> +	}
> +
>  	return j;
>  }


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [9front] Re: [9front] [PATCH] libjson: make sure string contains only a single JSON value
  2023-08-07 22:16 ` ori
@ 2023-08-08 14:44   ` Kristo
  2023-09-18 11:26     ` Kristo
  0 siblings, 1 reply; 5+ messages in thread
From: Kristo @ 2023-08-08 14:44 UTC (permalink / raw)
  To: 9front

On August 8, 2023 1:16:18 AM GMT+03:00, ori@eigenstate.org wrote:
>does this use the `l.buf` that we free one line up?

`buf` seems to be only used for copying literal and string values and therefore getting individual runes from the string should still be ok.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [9front] [PATCH] libjson: make sure string contains only a single JSON value
  2023-08-08 14:44   ` [9front] " Kristo
@ 2023-09-18 11:26     ` Kristo
  0 siblings, 0 replies; 5+ messages in thread
From: Kristo @ 2023-09-18 11:26 UTC (permalink / raw)
  To: 9front

On 8/8/23, Kristo <kristo.ilmari@gmail.com> wrote:
> On August 8, 2023 1:16:18 AM GMT+03:00, ori@eigenstate.org wrote:
>>does this use the `l.buf` that we free one line up?
>
> `buf` seems to be only used for copying literal and string values and
> therefore getting individual runes from the string should still be ok.
>

ping

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [9front] [PATCH] libjson: make sure string contains only a single JSON value
  2023-08-07 15:29 [9front] [PATCH] libjson: make sure string contains only a single JSON value Kristo
  2023-08-07 22:16 ` ori
@ 2023-09-18 12:59 ` ori
  1 sibling, 0 replies; 5+ messages in thread
From: ori @ 2023-09-18 12:59 UTC (permalink / raw)
  To: 9front

Quoth Kristo <kristo.ilmari@gmail.com>:
> diff bf645afaac246967b9590ae7463f243c11d97480 uncommitted
> --- a/sys/src/libjson/json.c
> +++ b/sys/src/libjson/json.c
> @@ -328,6 +328,13 @@
> 
>  	j = jsonobj(&l);
>  	free(l.buf);
> +
> +	if(peeknonspace(&l) != 0){
> +		jsonfree(j);
> +		werrstr("json: unexpected trailing data");
> +		return nil;
> +	}
> +
>  	return j;
>  }

thanks, committed.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-09-18 13:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-07 15:29 [9front] [PATCH] libjson: make sure string contains only a single JSON value Kristo
2023-08-07 22:16 ` ori
2023-08-08 14:44   ` [9front] " Kristo
2023-09-18 11:26     ` Kristo
2023-09-18 12:59 ` ori

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).