Xref: utzoo comp.unix.xenix:2627 comp.sources.d:2424
Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mandrill!hal!ncoast!allbery
From: allbery@ncoast.UUCP (Brandon S. Allbery)
Newsgroups: comp.unix.xenix,comp.sources.d
Subject: Re: tgetent core dump on sco xenix
Message-ID: <8233@ncoast.UUCP>
Date: 8 Jul 88 21:52:46 GMT
References: <54@libove.UUCP>
Reply-To: allbery@ncoast.UUCP (Brandon S. Allbery)
Followup-To: comp.unix.xenix
Distribution: comp
Organization: Cleveland Public Access UN*X, Cleveland, Oh
Lines: 29

As quoted from <54@libove.UUCP> by root@libove.UUCP (The Super User):
+---------------
| [root]/tmp:(1 ) % cat argle.c
| #include 
| #include 
| 
| main()
| 	{
| 	char	buffer[1024];
| 
| 	printf("%d\n",tgetent(buffer,getenv("TERM")));
| 	};
| [root]/tmp:(2 ) % cc -Ml2e -o argle argle.c -ltermcap
| argle.c
| [root]/tmp:(3 ) % ./argle
| ./argle: Segmentation violation -- Core dumped
+---------------

If you use large model you have to include an "extern char *getenv();", or
tgetent() will get a truncated pointer:  C passes an undeclared function
argument as an (int), which is 2 bytes, but a large-model (char *) is 4
bytes.  This is an example of a gratuitous 680x0/Vax-ism, nonportable to
systems where sizeof (int) != sizeof (char *).

The core dump occurs when tnamatch() tries to access the string passed to
it, and gets a pointer with a random value.
-- 
Brandon S. Allbery, uunet!marque!ncoast!allbery			DELPHI: ALLBERY
	    For comp.sources.misc send mail to ncoast!sources-misc