1266987Smarkj/*
2266987Smarkj * This file and its contents are supplied under the terms of the
3266987Smarkj * Common Development and Distribution License ("CDDL"), version 1.0.
4266987Smarkj * You may only use this file in accordance with the terms of version
5266987Smarkj * 1.0 of the CDDL.
6266987Smarkj *
7266987Smarkj * A full copy of the text of the CDDL should have accompanied this
8266987Smarkj * source.  A copy of the CDDL is also available via the Internet at
9266987Smarkj * http://www.illumos.org/license/CDDL.
10266987Smarkj */
11266987Smarkj
12266987Smarkj/*
13266987Smarkj * Copyright 2012, Joyent, Inc.  All rights reserved.
14266987Smarkj */
15266987Smarkj
16266987Smarkj/*
17266987Smarkj * ASSERTION:
18266987Smarkj *   json() run time must be bounded above by strsize.  This test makes strsize
19266987Smarkj *   small and deliberately overflows it to prove we bail and return NULL in
20266987Smarkj *   the event that we run off the end of the string.
21266987Smarkj *
22266987Smarkj */
23266987Smarkj
24266987Smarkj#pragma D option quiet
25266987Smarkj#pragma D option strsize=18
26266987Smarkj
27266987SmarkjBEGIN
28266987Smarkj{
29266987Smarkj	in = "{\"a\":         1024}"; /* length == 19 */
30266987Smarkj	out = json(in, "a");
31266987Smarkj	printf("|%s|\n%s\n\n", in, out != NULL ? out : "<NULL>");
32266987Smarkj
33266987Smarkj	in = "{\"a\": 1024}"; /* length == 11 */
34266987Smarkj	out = json(in, "a");
35266987Smarkj	printf("|%s|\n%s\n\n", in, out != NULL ? out : "<NULL>");
36266987Smarkj
37266987Smarkj	in = "{\"a\":false,\"b\":true}"; /* length == 20 */
38266987Smarkj	out = json(in, "b");
39266987Smarkj	printf("|%s|\n%s\n\n", in, out != NULL ? out : "<NULL>");
40266987Smarkj
41266987Smarkj	in = "{\"a\":false,\"b\":20}"; /* length == 18 */
42266987Smarkj	out = json(in, "b");
43266987Smarkj	printf("|%s|\n%s\n\n", in, out != NULL ? out : "<NULL>");
44266987Smarkj
45266987Smarkj	exit(0);
46266987Smarkj}
47266987Smarkj
48266987SmarkjERROR
49266987Smarkj{
50266987Smarkj	exit(1);
51266987Smarkj}
52