Ejemplo n.º 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
Ejemplo n.º 2
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
Ejemplo n.º 3
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()
Ejemplo n.º 4
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()