summaryrefslogtreecommitdiff
path: root/etc
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1999-09-04 21:07:24 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1999-09-04 21:07:24 +0000
commite3b08a79d1c361a37ec48ba587dc3b06b5a480bb (patch)
tree793326087388911182512c7ae54a118fd5fbc6e1 /etc
parentf78006eef602675e1ecf74b8cdea53a0fdc2c4ab (diff)
Check to make sure vi recovery files are normal files before trying
to read from them (this is a user-writable directory so it is possible to play games). Fixes a possible DOS noted by dynamo@ime.net. If it's not a regular file, we delete it.
Diffstat (limited to 'etc')
-rw-r--r--etc/rc15
1 files changed, 10 insertions, 5 deletions
diff --git a/etc/rc b/etc/rc
index 90042626013..6cf2a676e0a 100644
--- a/etc/rc
+++ b/etc/rc
@@ -1,4 +1,4 @@
-# $OpenBSD: rc,v 1.108 1999/09/03 18:11:48 deraadt Exp $
+# $OpenBSD: rc,v 1.109 1999/09/04 21:07:23 millert Exp $
# System startup script run by init on autoboot
# or after single-user.
@@ -340,7 +340,8 @@ if [ "$vibackup" != "/var/tmp/vi.recover/vi.*" ]; then
for i in $vibackup; do
# Unmodified vi editor backup files either have the
# execute bit set or are zero length. Delete them.
- if [ -x $i -o ! -s $i ]; then
+ # Anything that is not a normal file gets deleted too.
+ if [ -x $i -o ! -s $i -o ! -f $i ]; then
rm $i
fi
done
@@ -352,9 +353,13 @@ if [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then
# Delete any recovery files that are zero length, corrupted,
# or that have no corresponding backup file. Else send mail
# to the user.
- recfile=`awk '/^X-vi-recover-path:/{print $2}' < $i`
- if [ -n "$recfile" -a -s "$recfile" ]; then
- sendmail -t < $i
+ if [ -f $i ]; then
+ recfile=`awk '/^X-vi-recover-path:/{print $2}' < $i`
+ if [ -n "$recfile" -a -s "$recfile" ]; then
+ sendmail -t < $i
+ else
+ rm $i
+ fi
else
rm $i
fi