MAJOR BUG (what a hooter!)

John P. Linderman jpl at allegra.UUCP
Wed Apr 18 08:10:51 AEST 1984


Things are even worse than Philip Poulos let on.  Here is the routine he
suggested removing (a suggestion I am implementing as fast as `make' can run):

checkmodeline(line)
char *line;
{
	char *beg, *end;
	char cmdbuf[1024];
	char *index(), *rindex();

	beg = index(line, ':');
	if (beg == NULL)
		return;
	if (beg[-2] != 'e' && beg[-2] != 'v') return;
	if (beg[-1] != 'x' && beg[-1] != 'i') return;

	strncpy(cmdbuf, beg+1, sizeof cmdbuf);
	end = rindex(cmdbuf, ':');
	if (end == NULL)
		return;
	*end = 0;
	globp = cmdbuf;
	commands(1, 1);
}

Because of the way it checks for "ex:" or "vi:", it will also accept
"ei:" or "vx:".  Because of the way it fails to check that the ':'
is at least 2 characters into the line, it might also accept "x:",
"i:" or just ":", depending on the state of the chars in front of
the linebuf array.  If you are willing to live with this "feature",
you probably won't care about accepting bogus keywords, but you can
sleep a little easier if you do something like

	if ((beg == NULL) || (beg < (line + 2)))
		return;
	if (strncmp(beg-2, "ex", 2) && strncmp(beg-2, "vi", 2))
		return;

John P. Linderman  Department of Fun Software  allegra!jpl



More information about the Comp.unix.wizards mailing list