[FFmpeg-cvslog] compat/cuda/ptx2c: remove bashism and harden against arbitrary input

Timo Rothenpieler git at videolan.org
Mon May 15 19:55:16 EEST 2017


ffmpeg | branch: master | Timo Rothenpieler <timo at rothenpieler.org> | Mon May 15 18:05:10 2017 +0200| [88896c46196e4cca2afa6df6e2bc37ecfc2c4e98] | committer: Timo Rothenpieler

compat/cuda/ptx2c: remove bashism and harden against arbitrary input

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=88896c46196e4cca2afa6df6e2bc37ecfc2c4e98
---

 compat/cuda/ptx2c.sh | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/compat/cuda/ptx2c.sh b/compat/cuda/ptx2c.sh
old mode 100644
new mode 100755
index 987b0c4501..1f37023290
--- 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
-



More information about the ffmpeg-cvslog mailing list