[unix-pc.bugs] Weird problem with vi... "Not that many lines in buffer"

lenny@icus.islp.ny.us (Lenny Tropiano) (09/26/88)

I just created this .signature file, and for some reason every time this
is in a file, and I do a "vi" of that file I get the following message...

".signature" 4 lines of 300 characters Not that many lines in buffer

I've tried all kinds of things to alliviate this, I retyped the file 
(verbatim) and it still came back... I guess it doesn't like my .signature :-(
If you save this message (or try to reply to it) and vi is your editor, it
should crop up (at least on the UNIX PC).  Is something wrong with my
editor, should I reinstall the ENHANCED EDITORS?

-Lenny
-- 
Lenny Tropiano             ICUS Software Systems         w: +1 (516) 582-5525
lenny@icus.islp.ny.us      Telex: 154232428 ICUS         h: +1 (516) 968-8576
{talcott,boulder,hombre,pacbell,sbcs}!icus!lenny         attmail!icus!lenny
        ICUS Software Systems -- PO Box 1; Islip Terrace, NY  11752

honey@umix.cc.umich.edu (Peter Honeyman) (09/26/88)

your .signature file contains the string ... ex: ...

it's the MAJOR BUG FEATURE (so branded by john linderman).

	peter

jbm@uncle.UUCP (John B. Milton) (09/26/88)

In article <508@icus.islp.ny.us> lenny@icus.islp.ny.us (Lenny Tropiano) writes:
...
>".signature" 4 lines of 300 characters Not that many lines in buffer

Any time you get weird error messages from vi, always check on any recent
changes to the EXINIT environment variable, and changes to any .exrc files
you have laying around.

John
-- 
John Bly Milton IV, jbm@uncle.UUCP, n8emr!uncle!jbm@osu-cis.cis.ohio-state.edu
home: (614) 294-4823, work: (614) 459-7641; CP/M to MP/M, MS-DOS to OS/2

ccs@lazlo.UUCP (Clifford C. Skolnick) (09/27/88)

In article <508@icus.islp.ny.us> lenny@icus.islp.ny.us (Lenny Tropiano) writes:
>I just created this .signature file, and for some reason every time this
>is in a file, and I do a "vi" of that file I get the following message...
>
>".signature" 4 lines of 300 characters Not that many lines in buffer
>
>-Lenny
>-- 
>Lenny Tropiano             ICUS Software Systems         w: +1 (516) 582-5525
>lenny@icus.islp.ny.us      Telex: 154232428 ICUS         h: +1 (516) 968-8576
                              ^   ^ Here is the problem!

According to vi you are trying to go to line 154232428!  I found this
problem when I created a line "systex:XXXXX:...." in my passwd file.  Put
a space between the "ex" and the ":" or just change Telex to TELEX.





>{talcott,boulder,hombre,pacbell,sbcs}!icus!lenny         attmail!icus!lenny
>        ICUS Software Systems -- PO Box 1; Islip Terrace, NY  11752


-- 
Clifford C. Skolnick    | - You told me time makes it easy, then you never told
Phone: (716) 427-8046   |   me time stands still - Gary Neuman
PACKET: N1DPH@WB2WXQ    |  ...!rutgers!rochester!ritcv!ritcsh!sabin! lazlo!ccs
BITNET: CCS6277@RITVAX  |                       \!kodak!pcid!gizzmo!/

woods@ihlpe.ATT.COM (Swan) (09/27/88)

In article <508@icus.islp.ny.us> lenny@icus.islp.ny.us (Lenny Tropiano) writes:
>I just created this .signature file, and for some reason every time this
>is in a file, and I do a "vi" of that file I get the following message...
>
>".signature" 4 lines of 300 characters Not that many lines in buffer
>
>I've tried all kinds of things to alliviate this, I retyped the file 
>(verbatim) and it still came back... I guess it doesn't like my .signature :-(
>If you save this message (or try to reply to it) and vi is your editor, it
>should crop up (at least on the UNIX PC).  Is something wrong with my
>editor, should I reinstall the ENHANCED EDITORS?
>
>-Lenny
>-- 
>Lenny Tropiano             ICUS Software Systems         w: +1 (516) 582-5525
>lenny@icus.islp.ny.us      Telex: 154232428 ICUS         h: +1 (516) 968-8576
>{talcott,boulder,hombre,pacbell,sbcs}!icus!lenny         attmail!icus!lenny
>        ICUS Software Systems -- PO Box 1; Islip Terrace, NY  11752


Yes, I got the same response too.  The cause of it is an undocumented feature
of ex/vi that you are inadvertantly using but didn't know you were.

When vi starts to edit a file, it looks in the first 4 lines and the last 4
lines of that file for either vi: (that's vi followed by a colon), or
ex: (I'm trying to be careful I don't do the same thing!).  If later on the
same line there is another colon (:), vi assumes that the stuff between the
first part (ex colon or vi colon) and the later colon are some ex-mode commands
to do some set up, such as "ex: set showmatching :", which, if it were in the
first 4 lines or last 4 lines of this file, would automatically turn on the
showmatching mode of vi.

Now, go back and look at your signature line that starts: lenny@icus.islp...
Your Telex number is trying to tell vi (due to the later h:) to go to line
154232428 (and perform the "ICUS     h" command on it even)!!  Whoops!

Perhaps you could slip a . in after the Telex, as in: Telex.: 154...

Hope this helps.

Warren D. Swan  (WooDS)     Y n n ____  __
AT&T Bell Laboratories     -(((((([__]_)__]
Naperville, Illinois       /o-O-O-O oo  oo
ihlpe!woods             #####################

mike@turing.unm.edu (Michael I. Bushnell) (09/27/88)

Gee...I hate to point it out, but there is an editor which allows you
to have "ex: " or "vi: " in a file you edit.  Can you say EMACS?

Actually, GNU Emacs does have a similar feature, but there is
something to be said for the manner in which you envoke it.  To set
the major mode, you put the string "-*- ModeName -*-" at the front of
the file somewhere.  Pretty unlikely to see this in normal text.  In
the general case, you put "Local Variables:" near the end of the file,
and a list of variables, and then "End:".

I think it was a good decision to make this something which will not
occur in normal text frequently.  In fact, the design is such that it
is easy to write files which describe this behavior without it getting
in the way.
-- 
-- 
                N u m q u a m   G l o r i a   D e o 

       \                Michael I. Bushnell
        \               HASA - "A" division
        /\              mike@turing.unm.edu
       /  \ {ucbvax,gatech}!unmvax!turing.unm.edu!mike

dave@galaxia.zone1.com (David H. Brierley) (09/28/88)

In article <508@icus.islp.ny.us> lenny@icus.islp.ny.us (Lenny Tropiano) writes:
>I just created this .signature file, and for some reason every time this
>is in a file, and I do a "vi" of that file I get the following message...
>
>".signature" 4 lines of 300 characters Not that many lines in buffer
>-- 
>lenny@icus.islp.ny.us      Telex: 154232428 ICUS         h: +1 (516) 968-8576

The problem is that vi sees the string "ex:" and assumes that whatever follows,
up to the next colon, is to be interpreted as an ex (line mode) command.  This
behaviour is only exhibited in the first and last four lines of the file.  What
is happenning in this case is that vi is attempting to interpret "154232428" as
a line number!  I would assume that you dont have that many lines in your file,
hence the diagnostic is informing you of that fact.  The most common use of
these "mode lines" that I have seen is to specify various options that are
unique to the file, i.e. wm=72 sw=4 ts=4 etc.  One thing that can cause great
confusion when using mode lines is that not only is the string "ex:" recognized,
so are the strings "vi:", "vx:", and "ei:".

I know of several source sites (mine included) that have modified vi so that
mode lines are ignored by default and you have to take special action to get
the editor to honor them.  Not only can they cause confusion, as they did in
this case, they are also a potential security hole.
-- 
David H. Brierley
Home: dave@galaxia.zone1.com   ...!rayssd!galaxia!dave
Work: dhb@rayssd.ray.com       {sun,decuac,gatech,necntc,ukma}!rayssd!dhb

sac@conrad.UUCP (Steven A. Conrad) (09/28/88)

In article <508@icus.islp.ny.us> Lenny Tropiano writes:
>I just created this .signature file, and for some reason every time this
>is in a file, and I do a "vi" of that file I get the following message...
>
>".signature" 4 lines of 300 characters Not that many lines in buffer


The problem occurs on my 3B1 as well.  I tracked it down to the phrase
'Telex: 154232...'.  If you change the colon to something else, you
don't get the message.  It is interesing that the end of Telex: is
'ex:', so maybe vi is trying to interpret embedded code (I never knew it
could!).  I don't have time to run this down further, but if anyone does,
please let me know what you find.

	Steve Conrad

-- 
Steven A. Conrad,  Department of Medicine (Critical Care)
Louisiana State University Medical Center, Shreveport, LA
UUCP: sac@conrad.UUCP,   Internet: conrad@manta.pha.pa.us

jay@banzai.UUCP (Jay Schuster) (09/29/88)

In article <508@icus.islp.ny.us> lenny@icus.islp.ny.us (Lenny Tropiano) writes:
>I just created this .signature file, and for some reason every time this
>is in a file, and I do a "vi" of that file I get the following message...
>
>".signature" 4 lines of 300 characters Not that many lines in buffer
...
>-- 
>Lenny Tropiano             ICUS Software Systems         w: +1 (516) 582-5525
>lenny@icus.islp.ny.us      Telex: 154232428 ICUS         h: +1 (516) 968-8576
>{talcott,boulder,hombre,pacbell,sbcs}!icus!lenny         attmail!icus!lenny
>        ICUS Software Systems -- PO Box 1; Islip Terrace, NY  11752

vi has a feature that allows you to embed commands in the file you are
editing.  If, in the last N or first N lines of the file it finds a string
that goes `ex:', it assumes that what follows is a command to be executed.

I often put ex:set wm=15 in certain text logfiles I maintain.

Note that your .signature now has a Telex number that corresponds with that
format.

-- 
Jay Schuster				uunet!uvm-gen!banzai!jay
The People's Computer Company		`Revolutionary Programming'

jbm@uncle.UUCP (John B. Milton) (10/03/88)

In article <132@conrad.UUCP> sac@conrad.UUCP (Steven A. Conrad) writes:
>In article <508@icus.islp.ny.us> Lenny Tropiano writes:
...

This does make one think, now that everone knows that this can be done!
HP took care of it in their vi, you just can't do it; no switch to enable or
anything. It is indeed a big security hole. NEVER vi a user file from root,
you never know what might be in it! Below is a program "vick", which will
scan stdin or a list of files for these commands. It only looks at the first
four and the last four lines, and for ex, ei, vi and vx. The command passed to
vi seems to be from the : after "vi" to the LAST colon on the line. If you are
not using this on a UNIXpc, check your local vi and tune it accordingly.
Always look for strange vi behavior, it can come from: the environment variable
EXINIT, from ./.exrc, /.exrc, these imbedded vi:: commands, functions and 
aliases picked up here and there, weirdness from shelling out of other programs.

P.S. HP correctly fixed the problem with a :set modelines defaulted to no

---cut---cut---cut---cut---cut---cut---cut---
/* vi:set ai sm ts=2 sw=2: */

#include <stdio.h>
#include <string.h>

extern int errno;
extern int optind;
extern char *optarg;

#define VIMAXLINESIZE 1000

static char *me,Verbose=0;

void perrorf(format,a1,a2,a3,a4,a5,a6,a7,a8,a9)
char *format,*a1,*a2,*a3,*a4,*a5,*a6,*a7,*a8,*a9;
{
	char line[200];

	sprintf(line,format,a1,a2,a3,a4,a5,a6,a7,a8,a9);
	perror(line);
}

static int HasExCmd(s)
char *s;
{ /* sort of-> [ev][ix]:.*: */
	int i;
	char *colon;

	if ((colon=strchr(s,':'))==NULL)
		return(0); /* no colon */
	if (colon-s<2)
		return(0); /* colon too close to beginning to have vi */
	colon--;
	if (*colon!='i' && *colon!='x')
		return(0); /* character before : is not i|x */
	colon--;
	if (*colon!='v' && *colon!='e')
		return(0); /* character before : is not v|e */
	if (strchr(colon+3,':')==NULL)
		return(0); /* no second colon, command ignored */
	else {
		if (Verbose) {
			fputs(s,stdout);
			for (i=0; i<colon-s; i++)
				putchar(' ');
			puts("^");
		}
		return(1); /* GOT ONE! */
	}
}

static int filt(f)
FILE *f;
{
	int i;
	long int l=0;
	char line[4][VIMAXLINESIZE];

	while (fgets(line[l%4],VIMAXLINESIZE,f)!=NULL) {
		if (l<4 && HasExCmd(line[l%4])) /* will ALWAYS eval left to right! */
			return(1);
		l++;
	}
	if (l>4)
		for (i=l-4; i<l; i++)
			if (i>=4)
				if (HasExCmd(line[i%4]))
					return(1);
	return(0);
}

static char *usage="Usage: %s\n";

int main(argc,argv)
int argc;
char *argv[];
{
	int bad=0,i,opt;
	FILE *f;

	me=argv[0];
	while ((opt=getopt(argc,argv,"v?"))!=EOF)
		switch (opt) {
			case 'v':
				Verbose=1;
				break;
			case '?':
			default:
				fprintf(stderr,usage,me);
				exit(1);
				break;
		}
	if (argc==optind)
		bad+=filt(stdin);
	else
		for (i=optind; i<argc; i++)
			if ((f=fopen(argv[i],"r"))==NULL)
				perrorf("%s: open %s for reading",me,argv[i]);
			else {
				bad+=filt(f);
				fclose(f);
			}
	return(bad);
}

John
-- 
John Bly Milton IV, jbm@uncle.UUCP, n8emr!uncle!jbm@osu-cis.cis.ohio-state.edu
home (614) 294-4823, work (614) 764-4272; ei:wq!: (isn't vi fun?)

bzs@xenna (Barry Shein) (10/06/88)

In GNU emacs you can also put

	(setq inhibit-local-variables t)

in your .emacs file which causes it to prompt you before executing any
embedded local stuff. I think it's a good idea and should be in vi/ex
if it isn't, that's dangerous stuff otherwise, particularly if su'd.

	-Barry Shein, ||Encore||