aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorcmaynard <cmaynard@f5534014-38df-0310-8fa8-9805f1628bb7>2011-02-14 01:44:15 +0000
committercmaynard <cmaynard@f5534014-38df-0310-8fa8-9805f1628bb7>2011-02-14 01:44:15 +0000
commit18b7a8263de0cbe3d07e23f7f2dc7324741c67df (patch)
treebe8910a85a8de079ebd032b661174bfa980daf59 /tools
parent059b932911a5779470f4fd793414d7c5b0d48a6a (diff)
Disallow invalid char's in the filename passed to idl2wrs. Fixes bug 1129.
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@35944 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'tools')
-rw-r--r--tools/idl2wrs.sh.in19
1 files changed, 19 insertions, 0 deletions
diff --git a/tools/idl2wrs.sh.in b/tools/idl2wrs.sh.in
index 9fa33ba0be..ec3a4cfa4c 100644
--- a/tools/idl2wrs.sh.in
+++ b/tools/idl2wrs.sh.in
@@ -48,6 +48,25 @@ if [ $# -lt 1 ]; then
exit 1;
fi
+# Check the file name for valid characters.
+# Implementation based on Dave Taylor's validalnum shell script from his book,
+# "Wicked Cool Shell Scripts", as well as Mark Rushakoff's answer he provided
+# to the question posted at stackoverflow.com entitled, "How can I use the
+# UNIX shell to count the number of times a letter appears in a text file?"
+file=$(basename $1)
+compressed="$(echo $file | sed 's/[^[:alnum:]._]//g')"
+if [ "$compressed" != "$file" ]; then
+ echo "idl2wrs Error: Invalid file name: $file"
+ exit 1;
+fi
+
+# Only allow one '.' at most.
+count=$(echo $compressed | awk -F. '{c += NF - 1} END {print c}')
+if [ $count -gt 1 ] ; then
+ echo "idl2wrs Error: Invalid file name: $file"
+ exit 1;
+fi
+
#
# Run wireshark backend, looking for wireshark_be.py and wireshark_gen.py
# in pythons's "site-packages" directory. If cannot find that, then