mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-02-03 13:24:05 +00:00
compat/cuda/ptx2c: remove bashism and harden against arbitrary input
This commit is contained in:
parent
f0435bbe17
commit
88896c4619
12
compat/cuda/ptx2c.sh
Normal file → Executable file
12
compat/cuda/ptx2c.sh
Normal file → Executable file
@ -1,3 +1,5 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
# Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
|
# Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
|
||||||
#
|
#
|
||||||
# Permission is hereby granted, free of charge, to any person obtaining a
|
# Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
@ -22,15 +24,13 @@ set -e
|
|||||||
|
|
||||||
OUT="$1"
|
OUT="$1"
|
||||||
IN="$2"
|
IN="$2"
|
||||||
NAME="$(basename "$IN")"
|
NAME="$(basename "$IN" | sed 's/\..*//')"
|
||||||
NAME="${NAME/.ptx/}"
|
|
||||||
|
|
||||||
echo -n "const char ${NAME}_ptx[] = \\" > "$OUT"
|
printf "const char %s_ptx[] = \\" "$NAME" > "$OUT"
|
||||||
while read LINE
|
while read LINE
|
||||||
do
|
do
|
||||||
echo -ne "\n\t\"$LINE\\\n\"" >> "$OUT"
|
printf "\n\t\"%s\\\n\"" "$(printf "%s" "$LINE" | sed 's/["\\]/\\&/g')" >> "$OUT"
|
||||||
done < "$IN"
|
done < "$IN"
|
||||||
echo ";" >> "$OUT"
|
printf ";\n" >> "$OUT"
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user