🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.text
Article #742

Re: DWB tbl bug!! HELP

#742
From: Head UNIX Hacquer
Date: Wed, 05 Feb 1986 15:16
33 lines
1871 bytes
>	The problem arises when something scribbles 4 bytes into the input
>	buffer of (FILE *)tabin.
>	It occurs during the call to frearr() after the first table
>	finishes printing when the alloc'd memory is freed.
>	I think the problem is caused by the allocation at line 291 of t4.c
>	in routine garray() and the problem seems to have gone away by increasing
>	the allocation to 'sep' by one int.:
>		sep = (int *) getcore(qcol+2, sizeof(int));
==>		sep++; /* sep[-1] must be legal */

The actual problem is in freearr() on line 321:

	cfree(sep);
--- should be
	cfree(--sep);

Because of the 'sep++;' (pointed to above).  Malloc stores the size of
the chunk allocated in the previous word and if you don't free()
(which is all that cfree() really is) the SAME memory address that
you are given by malloc()/calloc(), free() does not get the proper
size of the memory chunk being freed.

This ends up corrupting malloc's allocation arena. If you are lucky,
causes buffering problems and if you are not lucky, segmentation faults
or bus errors.
-- 
Shouter-To-Dead-Parrots @ Univ. of Texas Computation Center; Austin, Texas  

"If you can't say something nice, say something surrealistic"
	- Zippy the Pinhead

	clyde@ngp.UTEXAS.EDU, clyde@sally.UTEXAS.EDU
	...!ihnp4!ut-ngp!clyde, ...!allegra!ut-ngp!clyde
Technical Details
Message-ID: <2915@ut-ngp.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!cbosgd!gatech!ut-sally!ut-ngp!clyde
References: <98@calgary.UUCP> <121@mm730.uq.OZ>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!cbosgd!gatech!ut-sally!ut-ngp!clyde
From: clyde@ut-ngp.UUCP (Head UNIX Hacquer)
Newsgroups: net.text,net.bugs
Subject: Re: DWB tbl bug!! HELP
Message-ID: <2915@ut-ngp.UUCP>
Date: Wed, 5-Feb-86 10:16:05 EST
Article-I.D.: ut-ngp.2915
Posted: Wed Feb  5 10:16:05 1986
Date-Received: Fri, 7-Feb-86 06:16:40 EST
References: <98@calgary.UUCP> <121@mm730.uq.OZ>
Distribution: net
Organization: UTexas Computation Center, Austin, Texas
Lines: 33