diff options
author | Chris Maynard <Christopher.Maynard@GTECH.COM> | 2011-02-14 01:44:15 +0000 |
---|---|---|
committer | Chris Maynard <Christopher.Maynard@GTECH.COM> | 2011-02-14 01:44:15 +0000 |
commit | 25d68e6c5b601ba3eb5f6425d3576a54d2a846ab (patch) | |
tree | be8910a85a8de079ebd032b661174bfa980daf59 /tools | |
parent | 3c54ea00a9770f728ded3bf1cb82477c46b37e91 (diff) |
Disallow invalid char's in the filename passed to idl2wrs. Fixes bug 1129.
svn path=/trunk/; revision=35944
Diffstat (limited to 'tools')
-rw-r--r-- | tools/idl2wrs.sh.in | 19 |
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 |