SQLite

Check-in [7c7a3f3e9b]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Do not allow a comma at the end of a JSON array or object.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 7c7a3f3e9bc2f7a7334d8d6eae183d83f22097be
User & Date: drh 2015-09-23 01:10:29.723
Context
2015-09-23
11:59
Capture AFL-generated fuzz tests for json1.c into the test/fuzzdata4.db file. (check-in: 10a214fdb3 user: drh tags: trunk)
01:10
Do not allow a comma at the end of a JSON array or object. (check-in: 7c7a3f3e9b user: drh tags: trunk)
2015-09-22
18:51
Add the --export-sql and --export-db options to the fuzzcheck utility program. (check-in: 760af44551 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to ext/misc/json1.c.
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
    /* Parse object */
    iThis = jsonParseAddNode(pParse, JSON_OBJECT, 0, 0);
    if( iThis<0 ) return -1;
    for(j=i+1;;j++){
      while( safe_isspace(pParse->zJson[j]) ){ j++; }
      x = jsonParseValue(pParse, j);
      if( x<0 ){
        if( x==(-2) ) return j+1;
        return -1;
      }
      if( pParse->oom ) return -1;
      pNode = &pParse->aNode[pParse->nNode-1];
      if( pNode->eType!=JSON_STRING ) return -1;
      pNode->jnFlags |= JNODE_LABEL;
      j = x;







|







602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
    /* Parse object */
    iThis = jsonParseAddNode(pParse, JSON_OBJECT, 0, 0);
    if( iThis<0 ) return -1;
    for(j=i+1;;j++){
      while( safe_isspace(pParse->zJson[j]) ){ j++; }
      x = jsonParseValue(pParse, j);
      if( x<0 ){
        if( x==(-2) && pParse->nNode==(u32)iThis+1 ) return j+1;
        return -1;
      }
      if( pParse->oom ) return -1;
      pNode = &pParse->aNode[pParse->nNode-1];
      if( pNode->eType!=JSON_STRING ) return -1;
      pNode->jnFlags |= JNODE_LABEL;
      j = x;
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
    /* Parse array */
    iThis = jsonParseAddNode(pParse, JSON_ARRAY, 0, 0);
    if( iThis<0 ) return -1;
    for(j=i+1;;j++){
      while( safe_isspace(pParse->zJson[j]) ){ j++; }
      x = jsonParseValue(pParse, j);
      if( x<0 ){
        if( x==(-3) ) return j+1;
        return -1;
      }
      j = x;
      while( safe_isspace(pParse->zJson[j]) ){ j++; }
      c = pParse->zJson[j];
      if( c==',' ) continue;
      if( c!=']' ) return -1;







|







632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
    /* Parse array */
    iThis = jsonParseAddNode(pParse, JSON_ARRAY, 0, 0);
    if( iThis<0 ) return -1;
    for(j=i+1;;j++){
      while( safe_isspace(pParse->zJson[j]) ){ j++; }
      x = jsonParseValue(pParse, j);
      if( x<0 ){
        if( x==(-3) && pParse->nNode==(u32)iThis+1 ) return j+1;
        return -1;
      }
      j = x;
      while( safe_isspace(pParse->zJson[j]) ){ j++; }
      c = pParse->zJson[j];
      if( c==',' ) continue;
      if( c!=']' ) return -1;
Changes to test/json101.test.
301
302
303
304
305
306
307












308
309
310
} {}
do_execsql_test json-5.8 {
  SELECT j2.rowid, jx.rowid, fullkey, path, key
    FROM j2, json_tree(j2.json) AS jx
   WHERE jx.value<>jx.atom AND type NOT IN ('array','object');
} {}















finish_test







>
>
>
>
>
>
>
>
>
>
>
>



301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
} {}
do_execsql_test json-5.8 {
  SELECT j2.rowid, jx.rowid, fullkey, path, key
    FROM j2, json_tree(j2.json) AS jx
   WHERE jx.value<>jx.atom AND type NOT IN ('array','object');
} {}

do_execsql_test json-6.1 {
  SELECT json_valid('{"a":55,"b":72,}');
} {0}
do_execsql_test json-6.2 {
  SELECT json_valid('{"a":55,"b":72}');
} {1}
do_execsql_test json-6.3 {
  SELECT json_valid('["a",55,"b",72,]');
} {0}
do_execsql_test json-6.4 {
  SELECT json_valid('["a",55,"b",72]');
} {1}


finish_test