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

Crash from swift driver calling bson_init_from_json

    XMLWordPrintable

    Details

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

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: