aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Maynard <Christopher.Maynard@GTECH.COM>2011-02-14 01:44:15 +0000
committerChris Maynard <Christopher.Maynard@GTECH.COM>2011-02-14 01:44:15 +0000
commit25d68e6c5b601ba3eb5f6425d3576a54d2a846ab (patch)
treebe8910a85a8de079ebd032b661174bfa980daf59
parent3c54ea00a9770f728ded3bf1cb82477c46b37e91 (diff)
Disallow invalid char's in the filename passed to idl2wrs. Fixes bug 1129.
svn path=/trunk/; revision=35944
-rw-r--r--doc/README.idl2wrs4
-rw-r--r--docbook/wsug_src/WSUG_app_tools.xml2
-rw-r--r--tools/idl2wrs.sh.in19
3 files changed, 22 insertions, 3 deletions
diff --git a/doc/README.idl2wrs b/doc/README.idl2wrs
index 974356d011..dae1f2a416 100644
--- a/doc/README.idl2wrs
+++ b/doc/README.idl2wrs
@@ -63,7 +63,7 @@ Procedure
1. To write the C code to stdout.
- idl2wrs <your file.idl>
+ idl2wrs <your_file.idl>
eg: idl2wrs echo.idl
@@ -81,7 +81,7 @@ steps 3 or 4 instead.
3. To write the C code to stdout.
- Usage: omniidl -p ./ -b wireshark_be <your file.idl>
+ Usage: omniidl -p ./ -b wireshark_be <your_file.idl>
eg: omniidl -p ./ -b wireshark_be echo.idl
diff --git a/docbook/wsug_src/WSUG_app_tools.xml b/docbook/wsug_src/WSUG_app_tools.xml
index 3aae21569a..7f8f30ded5 100644
--- a/docbook/wsug_src/WSUG_app_tools.xml
+++ b/docbook/wsug_src/WSUG_app_tools.xml
@@ -941,7 +941,7 @@ Miscellaneous:
<listitem>
<para>
To write the C code to stdout.
- <programlisting>idl2wrs &lt;your file.idl&gt;</programlisting>
+ <programlisting>idl2wrs &lt;your_file.idl&gt;</programlisting>
e.g.: <programlisting>idl2wrs echo.idl</programlisting>
</para>
</listitem>
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