FIX-TO-FIX: UNIX-pc vi "modelines" disable patch
Robert E. Stampfli
res at cbnews.ATT.COM
Sat Dec 3 07:12:53 AEST 1988
In article <405 at limbic.UUCP> gil at limbic.UUCP (Gil Kloepfer Jr.) writes:
>My apologies in advance for this. THIS VERSION OF THE PATCH WORKS!
Welllll, it didn't work for me, so I went into my vi and found
the string that Gil and Larry were talking about. Then I modified
the program to use this offset and fixed a few bugs in the the logic.
The results appear to work on my machine for both the encryption and
non-encryption versions of vi. I am running version 3.5, and can
almost certainly guarantee that the mods will not work on 3.51. (I do
have access to 3.51, so I may play around with it if I have the time and
if there is interest.) I must say, I have no idea what this fix does or
why it works, so use it at your own risk.
BTW, kudos to the both Gil and Larry for figuring out how to kill this
abomination that should never have been part of vi in the first place.
Rob Stampfli
att!cbnews!res (work)
osu-cis!n8emr!kd8wk!res (home)
If you have had trouble with Gil's previous postings, try this one:
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create:
# Makefile
# README
# modetest
# vifix.c
# This archive created: Fri Dec 2 15:37:20 1988
export PATH; PATH=/bin:/usr/bin:$PATH
echo shar: "extracting 'Makefile'" '(399 characters)'
if test -f 'Makefile'
then
echo shar: "will not over-write existing file 'Makefile'"
else
sed 's/^ X//' << \SHAR_EOF > 'Makefile'
X#
X# Makefile to compile vifix.c (vi modeline elimination)
X# (c)1988 ICUS Software Systems UUCP: ...icus!software
X#
XCFLAGS=-v -O
XLDFLAGS=-s
XLIBS=/lib/crt0s.o /lib/shlib.ifile
X#
Xvifix: vifix.o
X @echo "Loading ..."
X $(LD) $(LDFLAGS) -o vifix vifix.o $(LIBS)
X @echo "Copying /usr/bin/vi to current directory ..."
X @cp /usr/bin/vi .
X @vifix
X @echo "Save old version, and copy \"vi\" to /usr/bin"
SHAR_EOF
if test 399 -ne "`wc -c < 'Makefile'`"
then
echo shar: "error transmitting 'Makefile'" '(should have been 399 characters)'
fi
fi
echo shar: "extracting 'README'" '(1465 characters)'
if test -f 'README'
then
echo shar: "will not over-write existing file 'README'"
else
sed 's/^ X//' << \SHAR_EOF > 'README'
Xvi/ex modeline feature disable patch ... Gil Kloepfer, ICUS Software Systems
X----------------------------------------------------------------------------
X
XThis program and its Makefile are used to disable the modeline feature in
Xvi/ex which can inadvertantly allow malicious users to send "infected" files
Xto privileged users and disrupt system activities.
X
XThe patch is applied by executing the makefile ($ make). The makefile will
Xcompile the patch program, copy the vi editor executable file into your
Xcurrent directory and apply the patch to this copy. You should then make
Xa copy of the original vi editor, and copy the new one over the old one.
X
X # make
X # cp /usr/bin/vi /usr/bin/vi.OLD
X # cp ./vi /usr/bin/vi
X
XThanks to Lenny Tropiano for the makefile. Those who feel more comfortable
Xapplying the patch without any makefiles, the procedure is as follows:
X
X # cc -v -o vifix vifix.c
X # cd /usr/bin
X # cp vi vi.OLD
X # whatever-path/vifix
X
XThe vifix program will inform you if the version of vi you are fixing is
Xsupported by the patch program. Note that this message will also appear if
Xthe patch is already applied.
X
XYou can check to see if the patch really worked by editing the file
X"modetest" with this shell archive with vi. If a bannered word prints
Xout at all, the patch did not successfully take effect.
X
XAny further questions about the patch can be directed to Gil Kloepfer
Xat ...icus!limbic!gil, gil at limbic.UUCP, or gil at icus.islp.ny.us
SHAR_EOF
if test 1465 -ne "`wc -c < 'README'`"
then
echo shar: "error transmitting 'README'" '(should have been 1465 characters)'
fi
fi
echo shar: "extracting 'modetest'" '(71 characters)'
if test -f 'modetest'
then
echo shar: "will not over-write existing file 'modetest'"
else
sed 's/^ X//' << \SHAR_EOF > 'modetest'
Xex:!banner "this":
Xei:!banner "is":
Xvx:!banner "a":
Xvi:!banner "test":
SHAR_EOF
if test 71 -ne "`wc -c < 'modetest'`"
then
echo shar: "error transmitting 'modetest'" '(should have been 71 characters)'
fi
fi
echo shar: "extracting 'vifix.c'" '(2105 characters)'
if test -f 'vifix.c'
then
echo shar: "will not over-write existing file 'vifix.c'"
else
sed 's/^ X//' << \SHAR_EOF > 'vifix.c'
X/*
X * vifix.c
X *
X * Program to patch UNIX-pc (3B1) "vi" editor so that the modeline
X * function is disabled.
X *
X * By Gil Kloepfer, Jr., Lenny Tropiano ICUS Software Systems 11/26/1988
X * Modified by Rob Stampfli, osu-cis!n8emr!kd8wk!res, 12/2/88
X *
X * Verified on AT&T Unix 3.5 for Unix-PC vi (encryption and non-encryption
X * version) only.
X *
X * Permission granted to redistribute without profit in the public domain
X * only. This header must remain in-tact as is. This program carries
X * no warranties, express or implied, and all consequences resulting from
X * the application of this patch are the sole responsibility of the user.
X *
X * Patch transforms the following byte pattern in vi -- this comment here
X * so that this program could be adapted to a newer version of vi:
X *
X * From:
X * 377 374 112 200 147 000 000 174 040
X * To:
X * 377 374 116 161 140 000 000 174 040
X *
X * This effectively skips over the modeline checking code in the editor.
X */
X
X#define NONCRYPT 26202L
X#define CRYPT 26482L
X
X#include <fcntl.h>
X
Xmain()
X{
X unsigned char buffer[3];
X int fd;
X
X if ((fd=open("vi",O_RDWR)) < 0) {
X perror("open");
X exit(1);
X }
X
X lseek(fd,NONCRYPT,0); /* check for ENHANCED EDITOR version */
X if (read(fd,buffer,3) != 3) {
X perror("read");
X exit(1);
X }
X
X if (buffer[0] != 0112 ||
X buffer[1] != 0200 ||
X buffer[2] != 0147) {
X printf("0112 0200 0147 -> %o %o %o\n",
X buffer[0], buffer[1], buffer[2]);
X printf("Not ENHANCED ED vsn. Checking ENCRYPT SET vsn.\n");
X lseek(fd,CRYPT,0); /* check for ENCRYPTION SET version */
X if (read(fd,buffer,3) != 3) {
X perror("read");
X exit(1);
X }
X if (buffer[0] != 0112 ||
X buffer[1] != 0200 ||
X buffer[2] != 0147) {
X printf("0112 0200 0147 -> %o %o %o\n",
X buffer[0], buffer[1], buffer[2]);
X printf("Version of vi not valid for this patch.\n");
X exit(1);
X }
X }
X
X lseek(fd,-3L,1); /* back up pointer 3 bytes */
X buffer[0]=(char)0116;
X buffer[1]=(char)0161;
X buffer[2]=(char)0140;
X write(fd,buffer,3);
X
X close(fd);
X printf("vi modeline elimination patch successfully applied\n");
X exit(0);
X}
SHAR_EOF
if test 2105 -ne "`wc -c < 'vifix.c'`"
then
echo shar: "error transmitting 'vifix.c'" '(should have been 2105 characters)'
fi
fi
exit 0
# End of shell archive
More information about the Unix-pc.sources
mailing list