tgetent core dump on sco xenix

Brandon S. Allbery allbery at ncoast.UUCP
Sat Jul 9 07:52:46 AEST 1988


As quoted from <54 at libove.UUCP> by root at libove.UUCP (The Super User):
+---------------
| [root]/tmp:(1 ) % cat argle.c
| #include <stdio.h>
| #include <sgtty.h>
| 
| 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



More information about the Comp.unix.xenix mailing list