mirror of
https://github.com/open-quantum-safe/liboqs.git
synced 2025-10-08 00:03:38 -04:00
* Increase stack size when using musl libc on Alpine This is probably not the best way to do it in long run, but I'm not sure how to detect libc version at compile time. * Fix free-check bug on Alpine * Extra symbols in shared library on Alpine * Activate Alpine builds * Only increase stack size if musl is present on Alpine This is not the most generic way to do it but hopefully will suffice * Temporarily enable Alpine builds * Simplify link option on Alpine
28 lines
1.1 KiB
Python
28 lines
1.1 KiB
Python
# SPDX-License-Identifier: MIT
|
|
|
|
import helpers
|
|
import pytest
|
|
import sys
|
|
|
|
###
|
|
# Checks that "free" is not used unprotected in the main OQS code.
|
|
###
|
|
@helpers.filtered_test
|
|
@pytest.mark.skipif(sys.platform.startswith("win"), reason="Not needed on Windows")
|
|
def test_free():
|
|
files = helpers.run_subprocess(['find', 'src', '-name', '*.c'])
|
|
files = helpers.run_subprocess(['grep', '-v', 'picnic/external'], input=files.encode('utf8'))
|
|
lines = helpers.run_subprocess(['xargs', 'grep', '[^_]free('], input=files.encode('utf8'), ignore_returncode=True)
|
|
lines = lines.split("\n")
|
|
okay = True
|
|
for line in lines:
|
|
if line == "": continue
|
|
if not('IGNORE free-check' in line):
|
|
okay = False
|
|
print("Suspicious `free` in " + line)
|
|
assert okay, "'free' is used in some files. These should be changed to 'OQS_MEM_secure_free' or 'OQS_MEM_insecure_free' as appropriate. If you are sure you want to use 'free' in a particular spot, add the comment '// IGNORE free-check' on the line where 'free' occurs."
|
|
|
|
if __name__ == "__main__":
|
|
import sys
|
|
pytest.main(sys.argv)
|