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

Crash from swift driver calling bson_init_from_json

    • Type: Icon: Bug Bug
    • Resolution: Gone away
    • Priority: Icon: Major - P3 Major - P3
    • 1.12.0
    • Affects Version/s: 1.10.1
    • Component/s: json, libbson
    • Labels:
      None

      A test in the Swift driver kaitlin.mahar wrote crashes with a null pointer access in bson_init_from_json:

      func testFailure() throws {
             // this works fine
             let extjson1 = "{\"a\" : [{\"$numberInt\": \"10\"}]}".data(using: .utf8)!
             let res1 = try Document(fromJSON: extjson1)
             print(res1)
      
             // this crashes
             let extjson2 = "{\"x\" : { \"$binary\" : {\"base64\" : \"\", \"subType\" : \"00\"}}}".data(using: .utf8)!
             let res2 = try Document(fromJSON: extjson2)
             print(res2)
         }
      

      Kaitlin is able to reproduce this using 1.10 but not in 1.9 on macOS. This seems like an issue with the C driver. I couldn't reproduce the crash on Linux, nor from calling bson_init_from_json with the same arguments directly in the C driver. But I have not yet tested the Swift test on macOS yet.

            Assignee:
            kevin.albertson@mongodb.com Kevin Albertson
            Reporter:
            kevin.albertson@mongodb.com Kevin Albertson
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: