From 7ef3fdec00afa28505c207644c44cfc750faa9e0 Mon Sep 17 00:00:00 2001 From: shdown Date: Mon, 3 Aug 2015 12:51:39 +0300 Subject: [PATCH] .travis.yml: add a wrapped functions grepper script --- .travis.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.travis.yml b/.travis.yml index e3e45656..f90e0ebd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -45,3 +45,22 @@ script: - CFLAGS="-Wformat -Wformat-security -Wextra -Wno-unused-parameter -Werror" make -j - (cd testcases && xvfb-run ./complete-run.pl --parallel=1 || (cat latest/complete-run.log; false)) - clang-format-3.5 -i $(find . -name "*.[ch]" | tr '\n' ' ') && git diff --exit-code || (echo 'Code was not formatted using clang-format!'; false) + - | + funcs='malloc|calloc|realloc|strdup|strndup|asprintf|write' + cstring='"([^"\\]|\\.)*"' + cchar="'[^\\\\]'|'\\\\.[^']*'" + regex="^([^'\"]|${cstring}|${cchar})*\<(${funcs})\>" + detected=0 + while IFS= read -r file; do + if { cpp -w -fpreprocessed "$file" || exit "$?"; } | grep -E -- "$regex"; then + echo "^ $file calls a function that has a safe counterpart." + detected=1 + fi + done << EOF + $(find -name '*.c' -not -name safewrappers.c -not -name strndup.c) + EOF + if [ "$detected" -ne 0 ]; then + echo + echo "Calls of functions that have safe counterparts were detected." + exit 1 + fi -- 2.39.5