Indirection through NULL pointer in bash-1.02

25 views
Skip to first unread message

Andrew Thomas

unread,
Jul 9, 1989, 5:37:33 PM7/9/89
to

Using a uVax II under Ultrix 2.0:

Bash 1.02 performs an indirection through a null pointer when given
the line:

Meta-TAB: expand-line

in the .inputrc file. In the following diff, funmap[i] == 0, but on a
vax, funmap[i]->name is not an error. No error is reported unless the
value of funmap[i]->name is outside the process space. The following
diff solved the problem for me, though it might not be the correct
solution:

*** readline.c.orig Thu Jul 6 13:36:14 1989
--- readline.c Sun Jul 9 17:12:00 1989
***************
*** 3797,3803 ****
{
register int i;

! for (i = 0; funmap[i]->name; i++)
if (stricmp (funmap[i]->name, string) == 0)
return (funmap[i]->function);
return ((Function *)NULL);
--- 3797,3803 ----
{
register int i;

! for (i = 0; funmap[i] && funmap[i]->name; i++)
if (stricmp (funmap[i]->name, string) == 0)
return (funmap[i]->function);
return ((Function *)NULL);
--

Andrew Thomas
and...@watsnew.waterloo.edu Systems Design Eng. University of Waterloo
"If a million people do a stupid thing, it's still a stupid thing." - Opus

Brian Fox

unread,
Jul 9, 1989, 10:21:40 PM7/9/89
to

Date: 9 Jul 89 21:37:33 GMT
From: utgpu!watmath!watcgl!and...@jarvis.csri.toronto.edu (Andrew Thomas)

Bash 1.02 performs an indirection through a null pointer ...

*** readline.c.orig Thu Jul 6 13:36:14 1989
--- readline.c Sun Jul 9 17:12:00 1989
***************
*** 3797,3803 ****
{
register int i;

! for (i = 0; funmap[i]->name; i++)
if (stricmp (funmap[i]->name, string) == 0)
return (funmap[i]->function);
return ((Function *)NULL);
--- 3797,3803 ----
{
register int i;

! for (i = 0; funmap[i] && funmap[i]->name; i++)
if (stricmp (funmap[i]->name, string) == 0)
return (funmap[i]->function);
return ((Function *)NULL);
--

Thanks, Andrew.

This happened in 1.02 because I made funmaps be dynamically allocated,
which changed the test conditions.

You patch is correct, but has too much code; the solution is

for (i = 0; funmap[i]; i++)

Brian

Reply all
Reply to author
Forward
0 new messages