Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
* illegal free in 'patch'
@ 1998-06-05  5:43 Michal Jaegermann
  0 siblings, 0 replies; only message in thread
From: Michal Jaegermann @ 1998-06-05  5:43 UTC (permalink / raw)
  To: bug-gnu-utils; +Cc: bugs, axp-list


In patch-2.5 function 're_input()' in inp.c may attempt to free
unallocated i_buffer and i_ptr resulting in a possible "Segmentation
violation".  This happens, for example, on Linux/Alpha with 
Red Hat distributed binaries patch-2.5-2.alpha.rpm.

An illegal free may occur when, in a chain of patches, patch attempts
to create a new file, which already exists, and this attempt is denied.
A call to 'reinitialize_almost_everything()', which follows, invokes
're_input()' and a disaster may happen if 'using_plan_a' was already
true.

The following simple fix prevents this:

--- patch-2.5/inp.c~	Mon Jul 21 11:59:46 1997
+++ patch-2.5/inp.c	Thu Jun  4 20:13:44 1998
@@ -58,8 +58,14 @@
 re_input()
 {
     if (using_plan_a) {
-	free (i_buffer);
-	free (i_ptr);
+	if (0 != i_buffer) {
+	    free (i_buffer);
+	    i_buffer = 0;
+	}
+	if (0 != i_ptr) {
+	    free (i_ptr);
+	    i_ptr = 0;
+	}
     }
     else {
 	close (tifd);

  Michal Jaegermann,
  michal@harddata.com
  michal@ellpspace.math.ualberta.ca

p.s. For a convenience of Red Hat distribution users here is a patch
to specs and SOURCES for patch-2.5-2,src.rpm to be used after 'rpm -i'.

begin 644 patch.patch.gz
M'XL("""`=S4"`W!A=&-H+G!A=&-H`&U3;4_;,!#^7/^*VP>DEKPU:5/:#*9N
MB"&AP2H*^XJ<Q$DM.8GEV(AN&C]]FNWTC4+5O)WO>>[NN3O/\V"YN+I<!AS+
M;.5%?NRWG&2OO8>5@J]<0#32_R2,DSB&<#:;(L=Q/H18Q(VJ`<80#9-XD@RC
M#C&?@Q>ZX1`<?0]A/D>P5%6%Q3J!Z[M'L#SP*"FCDI(6P1VN2-*9$?PBHJ5-
MG8`.A+Q[P@AN]6F$G/W[*D=PV?"UH.5*:M+%#P37HE$\V=,&#^1%ZLB-$IG&
M%)(G0<`%X3ZF?D6E3W(5<)4&9:T.2I-8^.5OY"R,)=0X00BMN;_)[INB+!=-
MHZ,&SU@$LN(;L#'N"NWG9&"+]2R/M\L*]BZ%&&S3Q53HHTZ7G!B<%7%TYD[`
M&4W=F14QI8*1?Y(**GRDB4ZR%:Y+PIH2.:>P;<<8;!?@ENIC!C>8E$14N*[A
MO+*F.6&,MQQGQ*^P7/D*LY0(B?T,?T&.!UJC9U++3>4EJ!HSUF18DAPJ4C5B
M#>D:!'G2LBC9'P"MP2B4(0?!*7P7M!ND<9?'0C1F7&0C8+EN):G@/%5E.Q<D
M7V'I9TWUQ13C@12X;AF6NODM5$U."ZHC%AJ7$U=GXVH/*TL<&5GBB7MF9=%"
MF+;J1TNDXL@YL4*&X'%]I>";0JQ;:IJ'P`^RIBYHJ00!S]/8@KY<!*H5@#RS
M'S\?[R^OEL&;SK^^&?=1HB=^>+@@'V&.-B2:)-%LOR%#MUL0VUO'!-X-86#E
M?.W=-K7&,XA"",,DGB7CB<&?F9#.L?M1M'"4C,>;!*UH4W>J19NZX=@&/&B@
M_OBC+_.C!?15J[O^Q!FNG_#`G'@]4Q;TZ5.JBH*(P>=#&Y?6X/0,=@B?+F#G
M9\!.S_"^)^CL6PM<P-`:_QXQ&?;W-+N8'8?^/"2PE6R?A+7$EM?+6*-?^Y(6
,N0;_![^G?G$*!0``
`
end


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1998-06-05  5:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1998-06-05  5:43 illegal free in 'patch' Michal Jaegermann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox