$NetBSD: patch-ak,v 1.1 2004/02/25 03:58:43 snj Exp $

diff -u -r mm2.7.org/src/bin/showpartial mm2.7/src/bin/showpartial
--- bin/showpartial	Wed Feb  2 16:21:29 1994
+++ bin/showpartial	Wed May 21 21:39:49 1997
@@ -2,8 +2,44 @@
 # (The "-fb" might need to be changed to "-f" on some systems)
 #
 
+# Check argument integrity. Don't trust mail headers
+switch ("$1$2$3$4")
+case "*[\t ]*":
+  echo "Illegal white space in arguments\!"
+  echo "Command was:"
+  echo "'$0' '$1' '$2' '$3' '$4'"
+  exit 2
+endsw
+
+# Set a sensible value for the temporary directory, if its not
+# already set.  If TMPDIR is set previously, then we will
+# assume it is adequately protected.
 if (! $?METAMAIL_TMPDIR) then
-    set METAMAIL_TMPDIR=/tmp
+    if ($?TMPDIR) then
+        set METAMAIL_TMPDIR="$TMPDIR"
+    else
+        set METAMAIL_TMPDIR=~/metamail_tmp
+    endif
+endif
+
+# Set a sensible umask value
+umask 077
+
+# Make sure that the temporary directory is available
+if (! -d "$METAMAIL_TMPDIR") then
+
+    if (! -e "$METAMAIL_TMPDIR") then
+        mkdir "$METAMAIL_TMPDIR"
+    else
+        echo "$METAMAIL_TMPDIR exists, but is not a directory"
+        exit 2
+    endif
+
+    if ( $status != 0 || ! -d "$METAMAIL_TMPDIR" ) then
+        echo "Error creating $METAMAIL_TMPDIR"
+        exit 2
+    endif
+
 endif
 
 set TREEROOT=${METAMAIL_TMPDIR}/m-prts-`whoami`
@@ -11,14 +47,14 @@
     echo "Usage:  showpartial file id partnum totalnum"
     exit -1
 endif
-set file=$1
+set file="$1"
 # This next line is because message-id can contain weird chars
-set id=`echo $2 | tr -d  \!\$\&\*\(\)\|\'\"\;\/\<\>\\` 
-@ partnum = $3
-if ($#argv == 3 || $4 == "") then
+set id=`echo "$2" | tr -d  \!\$\&\*\(\)\|\'\"\;\/\<\>\\` 
+@ partnum = "$3"
+if ($#argv == 3 || "$4" == "") then
     set totalnum=-1
 else
-    @ totalnum = $4
+    @ totalnum = "$4"
 endif
 
 if (! -d  $TREEROOT)  then
@@ -35,9 +71,9 @@
         exit -1
     endif
 endif
-cp $file ${TREEROOT}/$id/$partnum
+cp "$file" ${TREEROOT}/$id/$partnum
 if ($status) then 
-    echo cp $file ${TREEROOT}/$id/$partnum failed
+    echo cp "$file" ${TREEROOT}/$id/$partnum failed
     exit -1
 endif
 if ($totalnum == -1) then