summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimo Rothenpieler <timo@rothenpieler.org>2017-05-15 18:05:10 +0200
committerTimo Rothenpieler <timo@rothenpieler.org>2017-05-15 18:54:38 +0200
commit88896c46196e4cca2afa6df6e2bc37ecfc2c4e98 (patch)
tree6805fa7e1e4e827308e07fa0b2ec5598e9b41aac
parentf0435bbe170d7e5232064c31d9c023c045386bab (diff)
downloadffmpeg-streaming-88896c46196e4cca2afa6df6e2bc37ecfc2c4e98.zip
ffmpeg-streaming-88896c46196e4cca2afa6df6e2bc37ecfc2c4e98.tar.gz
compat/cuda/ptx2c: remove bashism and harden against arbitrary input
-rwxr-xr-x[-rw-r--r--]compat/cuda/ptx2c.sh12
1 files changed, 6 insertions, 6 deletions
diff --git a/compat/cuda/ptx2c.sh b/compat/cuda/ptx2c.sh
index 987b0c4..1f37023 100644..100755
--- a/compat/cuda/ptx2c.sh
+++ b/compat/cuda/ptx2c.sh
@@ -1,3 +1,5 @@
+#!/bin/sh
+
# Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
@@ -22,15 +24,13 @@ set -e
OUT="$1"
IN="$2"
-NAME="$(basename "$IN")"
-NAME="${NAME/.ptx/}"
+NAME="$(basename "$IN" | sed 's/\..*//')"
-echo -n "const char ${NAME}_ptx[] = \\" > "$OUT"
+printf "const char %s_ptx[] = \\" "$NAME" > "$OUT"
while read LINE
do
-echo -ne "\n\t\"$LINE\\\n\"" >> "$OUT"
+ printf "\n\t\"%s\\\n\"" "$(printf "%s" "$LINE" | sed 's/["\\]/\\&/g')" >> "$OUT"
done < "$IN"
-echo ";" >> "$OUT"
+printf ";\n" >> "$OUT"
exit 0
-
OpenPOWER on IntegriCloud