Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-2693

Segfault in bson_b64_pton parsing valid BSON

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 1.10.3
    • Affects Version/s: 1.10.2
    • Component/s: libbson
    • Labels:
      None
    • Environment:
      CentOS 7
      cmake3

      installed via 

       

      cmake3 -DCMAKE_INSTALL_PREFIX=/usr -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF -DENABLE_BSON=ONLY -DCMAKE_BUILD_TYPE=Debug .
      cd src/libbson
      make
      make install
      
      

       

       

      #include <stdio.h>
      #include <bson.h>
      static void test_binary(){
       bson_t *b, *c;
       char *str;
       size_t len;
       b = bson_new ();
       const uint8_t binary[] = {0, 1, 2, 3, 4};
       BSON_ASSERT (bson_append_binary (b, "binary", -1, BSON_SUBTYPE_BINARY, binary, sizeof binary));
       str = bson_as_json (b, &len);
       //str = "{ \"binary\" : { \"$binary\" : \"AAECAwQ=\", \"$type\" : \"00\" } }"
       bson_error_t e;
       c = bson_new_from_json(str, len, &e);
       printf("%s\n", str);
       bson_free (str);
       bson_destroy (b);
      }
      int
      main (int argc,
       char *argv[])
      {
       test_binary();
       return 0;
      }
      

       

      bson_new_from_json calls

      bson_json_reader_read calls

      jsonsl_feed calls

      bson_b64_pton

       

      segfaults on line

      c = bson_new_from_json(str, len, &e);

       

            Assignee:
            jesse@mongodb.com A. Jesse Jiryu Davis
            Reporter:
            bauman Dan Bauman
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: