Skip to content

Commit

Permalink
Add buffer overflow test for C version
Browse files Browse the repository at this point in the history
This follows #6.
  • Loading branch information
starnight committed Dec 20, 2023
1 parent 15a37a0 commit c1d27a1
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions autotest/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,29 @@ def test_Scenario5(self):

def test_Scenario6(self):
cli = Client()
uri = "/" \
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
for i in range(10):
self.assertEqual(cli.test_Connect(server), 1)
res = cli.test_PostRequest("/index.html", None)
res = cli.test_GetRequest(uri)
self.assertIsNotNone(res)
self.assertEqual(res.status, 404)
self.assertEqual(res.read(22), b"")
self.assertEqual(cli.test_Close(), 1)

def test_Scenario7(self):
cli = Client()
for i in range(10):
self.assertEqual(cli.test_Connect(server), 1)
res = cli.test_PostRequest("/index.html", None)
self.assertIsNotNone(res)
self.assertEqual(res.status, 404)
self.assertEqual(cli.test_Close(), 1)

def test_Scenario8(self):
cli = Client()
for i in range(40):
self.assertEqual(cli.test_Connect(server), 1)
Expand All @@ -125,7 +140,7 @@ def test_Scenario7(self):
self.assertEqual(res.read(len(str.encode(pattern))), str.encode(pattern))
self.assertEqual(cli.test_Close(), 1)

def test_Scenario8(self):
def test_Scenario9(self):
cli = Client()
for i in range(40):
self.assertEqual(cli.test_Connect(server), 1)
Expand All @@ -136,7 +151,7 @@ def test_Scenario8(self):
self.assertEqual(res.read(len(str.encode(pattern))), str.encode(pattern))
self.assertEqual(cli.test_Close(), 1)

def test_Scenario9(self):
def test_Scenario10(self):
cli = Client()
for i in range(10):
self.assertEqual(cli.test_Connect(server), 1)
Expand Down

0 comments on commit c1d27a1

Please sign in to comment.