[comp.unix.microport] tgetstr stomps memory in SV/AT 2.4

" Maynard) (03/11/89)

I think, anyway.
I'm trying to recompile rn with SPEEDOVERMEM #undef'ed, to do away with
the core dump in large newsgroups. Unfortunately, when I try the
recompiled version, I get a memory fault in term_set, in term.c.

Examination of the code reveals that Larry Wall used the termcap
interface to the terminfo database. Well and good, and great for
portability, right? Except for one minor problem: when he does a
tgetstr("cm",&tmpaddr), the stack is clobbered. tmpaddr points to a
char[512].

Is this really a termcap/curses bug? Or is it more esoteric? I'm pretty
sure that it's 2.3- or 2.4-specific, since I'm running rn compiled last
April, and it runs fine (except for the article number problem).

-- 
Jay Maynard, EMT-P, K5ZC, PP-ASEL   | Never ascribe to malice that which can
uucp:        uunet!nuchat!   (eieio)| adequately be explained by stupidity.
    hoptoad!academ!uhnix1!splut!jay +----------------------------------------
{killer,bellcore}!texbell!          | "Less great!" "Tastes filling!"

rd@tarpit.UUCP (Bob Thrush x210) (03/13/89)

In article <2525@splut.UUCP> jay@splut.UUCP (Jay "you ignorant splut!" Maynard) writes about core dumps when running rn compiled with System V/AT Release 2.4 .
>
>Is this really a termcap/curses bug? Or is it more esoteric? I'm pretty
>sure that it's 2.3- or 2.4-specific, since I'm running rn compiled last
>April, and it runs fine (except for the article number problem).

  Yes, tgetstr is broken in 2.4 and 2.3.1.  In <316@tarpit.UUCP> and 
<322@tarpit.UUCP>, I described this problem.  In summary:

"tgetstr" should be used as:
     SYNOPSIS
          char *
          tgetstr(id, area)
          char *id, **area;
However, tgetstr behaves as though area is defined as "char *area".  My
patch to rn's "term.c" merely compensates for the error in tgetstr.  (This
could be fixed better by passing the #define from the Makefile.)

Here is the patch to term.c:

------------ snip here -----------

*** term.c	Fri Nov 21 17:39:32 1986
--- term.c.uport	Sat Nov 19 23:28:06 1988
***************
*** 33,39 ****
--- 33,45 ----
  /* guarantee capability pointer != Nullch */
  /* (I believe terminfo will ignore the &tmpaddr argument.) */
  
+ #define MICROPORT_286_CURSES_BUG
+ 
+ #ifdef MICROPORT_286_CURSES_BUG
+ #define Tgetstr(key) ((tmpstr = tgetstr(key,tcarea)) ? tmpstr : nullstr)
+ #else
  #define Tgetstr(key) ((tmpstr = tgetstr(key,&tmpaddr)) ? tmpstr : nullstr)
+ #endif MICROPORT_286_CURSES_BUG
  
  #ifdef PUSHBACK
  struct keymap {

------------ and here -----------

>
>-- 
>Jay Maynard, EMT-P, K5ZC, PP-ASEL   | Never ascribe to malice that which can
>uucp:        uunet!nuchat!   (eieio)| adequately be explained by stupidity.
>    hoptoad!academ!uhnix1!splut!jay +----------------------------------------
>{killer,bellcore}!texbell!          | "Less great!" "Tastes filling!"


-- 
Bob Thrush                 UUCP: {rtmvax,ucf-cs}!tarpit!rd
Automation Intelligence,   1200 W. Colonial Drive, Orlando, Florida 32804

plocher@uport.UUCP (John Plocher) (03/13/89)

In article <2525@splut.UUCP> Jay Maynard writes:
>
>Is this really a termcap/curses bug? Or is it more esoteric? I'm pretty
>sure that it's 2.3- or 2.4-specific, since I'm running rn compiled last
>April, and it runs fine (except for the article number problem).

We broke that one.  You can call texch support and get a version which declares
tgetstr to be a char* instead of char** (oops).  Or you can declare it "wrong"
in your program and live with it.  You can also grab it out of the 2.3 curses
library and replace the broken one in 2.4.

   John Plocher