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

Add example of validating BSON nesting depth with bson_visitor_t

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 1.14.0
    • Affects Version/s: 1.9.4
    • Component/s: Docs, libmongoc
    • Environment:
      Windows 10

      Original title: "Calling mongoc_collection_insert with a document which contains hundreds of levels of nested BSON documents causes stack overflow"

      I know that MongoDB only supports up to 100 levels of nesting for BSON documents but if someone unknowingly calls mongoc_collection_insert() and passes a document with >500 levels of nesting, then it causes stack overflow.

       

      The overflow happens while validating the BSON document. If I disable the validation by passing in MONGOC_INSERT_NO_VALIDATE, then of course, it doesn't crash.

       

      I understand that this is unsupported behavior, but it would be nice if it didn't cause stack overflow.

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

              Created:
              Updated:
              Resolved: