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

Segfault in bson_b64_pton parsing valid BSON

    XMLWordPrintable

    Details

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

      Description

      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);

       

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: