Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-571

invalid bson crashes parser

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.7
    • Affects Version/s: None
    • Component/s: None
    • None
    • Environment:
      linux x86-64

      1. The following crashes the bson parser of Pymongo 2.6+ (github master
      2. as of Thu Sep 19 16:07:21 PDT 2013). It's invalid bson because I'm
      3. trying to find valid bson strings in a corrupted customer file
      4. (not corrupted by us). Any help would be appreciated. I tried
      5. opening a ticket through MMS, but it repeatedly says
      6. "Yikes! Server error. Please try again in a minute." Note: earlier version
      7. 2.5.2 crashed even sooner. Any help would be appreciated.

      import bson

      charlist = [129, 1, 0, 0, 15, 3, 97, 117, 116, 104, 111, 114, 0, 98,
      0, 0, 0, 7, 95, 105, 100, 0, 81, 18, 253, 174, 199, 49, 179, 129, 106,
      0, 1, 57, 2, 102, 105, 114, 115, 116, 110, 97, 109, 101, 0, 7, 0, 0,
      0, 66, 97, 105, 108, 101, 101, 0, 2, 108, 97, 115, 116, 110, 97, 109,
      101, 0, 10, 0, 0, 0, 69, 100, 103, 105, 110, 103, 116, 111, 110, 0, 2,
      101, 109, 97, 105, 108, 0, 19, 0, 0, 0, 101, 100, 103, 105, 110, 103,
      116, 111, 110, 46, 98, 64, 109, 101, 46, 99, 111, 109, 0, 0, 3, 100,
      97, 116, 101, 115, 0, 39, 0, 0, 0, 1, 99, 114, 101, 97, 116, 105, 111,
      110, 0, 0, 112, 187, 113, 35, 213, 115, 66, 1, 117, 112, 100, 97, 116,
      101, 0, 0, 112, 187, 113, 35, 213, 115, 66, 0, 16, 112, 97, 103, 101,
      99, 111, 117, 110, 116, 0, 7, 0, 0, 0, 4, 112, 97, 103, 101, 115, 0,
      154, 10, 0, 0, 3, 48, 0, 120, 0, 0, 0, 2, 116, 101, 109, 112, 108, 97,
      116, 101, 0, 14, 0, 0, 0, 103, 101, 110, 101, 114, 105, 99, 95, 99,
      111, 118, 101, 114, 0, 4, 116, 97, 103, 115, 0, 18, 0, 0, 0, 2, 48, 0,
      6, 0, 0, 0, 99, 111, 118, 101, 114, 0, 0, 7, 95, 105, 100, 0, 81, 59,
      245, 136, 203, 150, 133, 129, 1, 0, 0, 16, 3, 100, 97, 116, 101, 115,
      0, 39, 0, 0, 0, 1, 99, 114, 101, 97, 116, 105, 111, 110, 0, 0, 0, 191,
      113, 35, 213, 115, 66, 1, 117, 112, 100, 97, 116, 101, 0, 0, 0, 191,
      113, 35, 213, 115, 66, 0, 0, 3, 49, 0, 162, 0, 0, 0, 3, 109, 101, 116,
      97, 0, 23, 0, 0, 0, 2, 100, 101, 115, 99, 114, 105, 112, 116, 105,
      111, 110, 0, 1, 0, 0, 0, 0, 0, 2, 116, 101, 109, 112, 108, 97, 116,
      101, 0, 13, 0, 0, 0, 103, 101, 110, 101, 114, 105, 99, 95, 108, 105,
      115, 116, 0, 4, 116, 97, 103, 115, 0, 32, 0, 0, 0, 2, 48, 0, 8, 0, 0]

      malformed_bson_string = str(bytearray(charlist))
      print malformed_bson_string
      print bson.BSON(malformed_bson_string).decode()

      1. above crashes with core dump.

            Assignee:
            bernie@mongodb.com Bernie Hackett
            Reporter:
            mhqpaul Paul Rubin
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: