timescaledb/scripts/coccinelle.sh
Sven Klemm 9e16d9f4e4 Add coccinelle scripts for detecting use-after-free
This patch adds coccinelle scripts for detecting use-after-free
bugs in relation to ts_cache_release.

This will find code using the following pattern:
Use of the hypertable from cache after releasing the cache
and use of the dimension of the hypertable from a cache
after the cache was released.
2022-01-28 01:43:16 +01:00

19 lines
381 B
Bash
Executable File

#!/bin/bash
set -o pipefail
SCRIPT_DIR=$(dirname "${0}")
FAILED=false
true > coccinelle.diff
for f in "${SCRIPT_DIR}"/../coccinelle/*.cocci; do
find "${SCRIPT_DIR}"/.. -name '*.c' -exec spatch --very-quiet -sp_file "$f" {} + | tee -a coccinelle.diff
rc=$?
if [ $rc -ne 0 ]; then
FAILED=true
fi
done
if [ $FAILED = true ] || [ -s coccinelle.diff ] ; then exit 1; fi