timescaledb/scripts/coccinelle.sh
Jan Nidzwetzki 330bb8f4af Added coccinelle rule to find strlcpy on NameData
NameData is a fixed-size type of 64 bytes. Using strlcpy to copy data
into a NameData struct can cause problems because any data that follows
the initial null-terminated string will also be part of the data.
2023-02-20 15:23:57 +01:00

19 lines
379 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
spatch --very-quiet --include-headers --sp-file "$f" --dir "${SCRIPT_DIR}"/.. | tee -a coccinelle.diff
rc=$?
if [ $rc -ne 0 ]; then
FAILED=true
fi
done
if [ $FAILED = true ] || [ -s coccinelle.diff ] ; then exit 1; fi