chbg: avoid the TOCTOU race

This commit is contained in:
2026-01-06 19:31:05 +08:00
parent 0ef0ef2562
commit ca2f125654

View File

@@ -14,7 +14,7 @@ finput=$1
read -r fw fh <<< "$fsize" read -r fw fh <<< "$fsize"
(( fw > 3840 && fh > 2160 )) && { (( fw > 3840 && fh > 2160 )) && {
finput="$(mktemp --dry-run).webp" finput=$(mktemp "${TMPDIR:-/tmp}/chbg.XXXXXXXX.webp")
trap 'rm -f "$finput"' EXIT trap 'rm -f "$finput"' EXIT
echo "WARNING: image too large, resizing ..." echo "WARNING: image too large, resizing ..."
# echo "DEBUG: resized image at $finput" # echo "DEBUG: resized image at $finput"