Beispiel #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
Beispiel #2
0
 def test_known_bad(self):
   for s in KNOWN_BAD:
     try:
       d = base64.b64decode(s)
       cbson.loads(d)
     except cbson.BSONError:
       pass
 def test_known_bad(self):
     for s in KNOWN_BAD:
         try:
             d = base64.b64decode(s)
             cbson.loads(d)
         except cbson.BSONError:
             pass
 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
Beispiel #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()
 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()
Beispiel #7
0
def cbson_decode_empty():
    cbson.loads(EMPTY_BSON)
Beispiel #8
0
def cbson_decode_with_id():
    cbson.loads(DOC_WITH_ID)
Beispiel #9
0
def cbson_decode_datetime_bson():
    cbson.loads(DATETIME_BSON)
Beispiel #10
0
def cbson_decode_25x_level():
    cbson.loads(_25X_BSON)
Beispiel #11
0
def cbson_decode_with_id():
    cbson.loads(DOC_WITH_ID)
Beispiel #12
0
def cbson_decode_datetime_bson():
    cbson.loads(DATETIME_BSON)
Beispiel #13
0
def cbson_decode_25x_level():
    cbson.loads(_25X_BSON)
Beispiel #14
0
def cbson_decode_empty():
    cbson.loads(EMPTY_BSON)