2 funcs='malloc|calloc|realloc|strdup|strndup|asprintf|write'
3 cstring='"([^"\\]|\\.)*"'
4 cchar="'[^\\\\]'|'\\\\.[^']*'"
5 regex="^([^'\"]|${cstring}|${cchar})*\<(${funcs})\>"
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."
13 $(find -name '*.c' -not -name safewrappers.c -not -name strndup.c)
15 if [ "$detected" -ne 0 ]; then
17 echo "Calls of functions that have safe counterparts were detected."