Skip to content

Commit

Permalink
Merge pull request #7 from starnight/buffer-overflow-test-for-c
Browse files Browse the repository at this point in the history
Add buffer overflow test for C version
  • Loading branch information
starnight authored Dec 20, 2023
2 parents 15a37a0 + 4559f40 commit 446d327
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 3 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Build

on:
push:
branches: [master]
pull_request:
workflow_dispatch:

jobs:
main:
runs-on: ubuntu-latest
strategy:
matrix:
lang_version: [c-version, py-version]

steps:
- uses: actions/checkout@v3

- name: Build
if: ${{ matrix.lang_version == 'c-version' }}
run: |
cd ${{ matrix.lang_version }}
make
- name: Run & Test
if: ${{ matrix.lang_version == 'c-version' }}
run: |
cd ${{ matrix.lang_version }}
./microhttpserver &
../autotest/client.py localhost:8001
- name: Run & Test
if: ${{ matrix.lang_version == 'py-version' }}
run: |
cd ${{ matrix.lang_version }}
./main.py &
../autotest/client.py localhost:8000
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 446d327

Please sign in to comment.