]> git.sur5r.net Git - i3/i3/blob - travis/check-safe-wrappers.sh
travis/cleanup-bintray: use dpkg --compare-versions (#2453)
[i3/i3] / travis / check-safe-wrappers.sh
1 #!/bin/sh
2 funcs='malloc|calloc|realloc|strdup|strndup|asprintf|write'
3 cstring='"([^"\\]|\\.)*"'
4 cchar="'[^\\\\]'|'\\\\.[^']*'"
5 regex="^([^'\"]|${cstring}|${cchar})*\<(${funcs})\>"
6 detected=0
7 while IFS= read -r file; do
8     if { cpp -w -fpreprocessed "$file" || exit "$?"; } | grep -E -- "$regex"; then
9         echo "^ $file calls a function that has a safe counterpart."
10         detected=1
11     fi
12 done << EOF
13 $(find -name '*.c' -not -name safewrappers.c -not -name strndup.c)
14 EOF
15 if [ "$detected" -ne 0 ]; then
16     echo
17     echo "Calls of functions that have safe counterparts were detected."
18     exit 1
19 fi