Example #1
0
 def test_short_string_segfaults(self):
   a = cbson.dumps({"A": [1, 2, 3, 4, 5, "6", u"7", {"C": u"DS"}]})
   for i in range(len(a))[1:]:
     try:
       cbson.loads(a[:-i] + (" " * i))
     except Exception:
       pass
Example #2
0
 def test_known_bad(self):
   for s in KNOWN_BAD:
     try:
       d = base64.b64decode(s)
       cbson.loads(d)
     except cbson.BSONError:
       pass
Example #3
0
 def test_known_bad(self):
     for s in KNOWN_BAD:
         try:
             d = base64.b64decode(s)
             cbson.loads(d)
         except cbson.BSONError:
             pass
Example #4
0
 def test_short_string_segfaults(self):
     a = cbson.dumps({"A": [1, 2, 3, 4, 5, "6", u"7", {"C": u"DS"}]})
     for i in range(len(a))[1:]:
         try:
             cbson.loads(a[:-i] + (" " * i))
         except Exception:
             pass
Example #5
0
 def test_random_segfaults(self):
   a = cbson.dumps({"A": [1, 2, 3, 4, 5, "6", u"7", {"C": u"DS"}]})
   sys.stdout.write("\nQ: %s\n" % (binascii.hexlify(a),))
   for _ in range(1000):
     l = [c for c in a]
     l[random.randint(4, len(a)-1)] = chr(random.randint(0, 255))
     try:
       s = "".join(l)
       sys.stdout.write("s: %s\n" % (binascii.hexlify(s),))
       sys.stdout.flush()
       cbson.loads(s)
     except Exception as e:
       sys.stdout.write("  ERROR: %r\n" % (e,))
       sys.stdout.flush()
Example #6
0
 def test_random_segfaults(self):
     a = cbson.dumps({"A": [1, 2, 3, 4, 5, "6", u"7", {"C": u"DS"}]})
     sys.stdout.write("\nQ: %s\n" % (binascii.hexlify(a), ))
     for _ in range(1000):
         l = [c for c in a]
         l[random.randint(4, len(a) - 1)] = chr(random.randint(0, 255))
         try:
             s = "".join(l)
             sys.stdout.write("s: %s\n" % (binascii.hexlify(s), ))
             sys.stdout.flush()
             cbson.loads(s)
         except Exception as e:
             sys.stdout.write("  ERROR: %r\n" % (e, ))
             sys.stdout.flush()
Example #7
0
def cbson_decode_empty():
    cbson.loads(EMPTY_BSON)
Example #8
0
def cbson_decode_with_id():
    cbson.loads(DOC_WITH_ID)
Example #9
0
def cbson_decode_datetime_bson():
    cbson.loads(DATETIME_BSON)
Example #10
0
def cbson_decode_25x_level():
    cbson.loads(_25X_BSON)
Example #11
0
def cbson_decode_with_id():
    cbson.loads(DOC_WITH_ID)
Example #12
0
def cbson_decode_datetime_bson():
    cbson.loads(DATETIME_BSON)
Example #13
0
def cbson_decode_25x_level():
    cbson.loads(_25X_BSON)
Example #14
0
def cbson_decode_empty():
    cbson.loads(EMPTY_BSON)