From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (qmail 9309 invoked from network); 5 Jun 1998 05:43:45 -0000 Received: from ellpspace.math.ualberta.ca (michal@129.128.88.19) by mail2.redhat.com with SMTP; 5 Jun 1998 05:43:45 -0000 Received: (from michal@localhost) by ellpspace.math.ualberta.ca (8.8.8/8.8.8) id XAA20486; Thu, 4 Jun 1998 23:43:39 -0600 From: Michal Jaegermann Message-Id: <199806050543.XAA20486@ellpspace.math.ualberta.ca> Subject: illegal free in 'patch' To: bug-gnu-utils@prep.ai.mit.edu Date: Thu, 4 Jun 1998 23:43:39 -0600 (MDT) Cc: bugs@redhat.com, axp-list@redhat.com Content-Type: text 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>[NN3O/\V"YN+I5@J]<0#32_R2,DSB&<#:;(L=Q/H18Q(VJ`<80#9-XD@RC M#C&?@Q>ZX1`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";0JQ;:IJ'P`^RIBYHJ00!S]/8@KY+@@'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