Patch patch...
Dan Ts'o
dan at rna.UUCP
Sun Nov 25 08:58:51 AEST 1984
xyzzy
Larry Wall's patch program calls mktemp() with the same string
multiple times, which then begins to write all over string space.
mktemp() needs an ending "XXXXXX", but this is destroyed after the first
invocation on a given string. I haven't check out all the circumstances
when this bug occurs but probably with multiple patches which lead to
multiple rejections. The fix is not guaranteed, since I haven't had the
time to try to understand the program in its entirety, but it does seem
to work.
Alas things are still not well with patch - I occassionally get
core dumps in malloc(), via savestr(), but I haven't had a chance to
track that one down yet. It seems to happen when patch can't find the
appropriate file, but it may be something else. Sigh... A valiant
program, tho...
*** patch.c.org Sat Nov 24 16:45:27 1984
--- patch.c Sat Nov 24 17:08:30 1984
***************
*** 485,491
init_output(name)
char *name;
{
! mktemp(name);
ofp = fopen(name,"w");
if (ofp == Nullfp)
fatal("patch: can't create %s.\n",name);
--- 485,495 -----
init_output(name)
char *name;
{
! static int iflag = 0;
! if (!iflag) {
! mktemp(name);
! iflag++;
! }
ofp = fopen(name,"w");
if (ofp == Nullfp)
fatal("patch: can't create %s.\n",name);
***************
*** 494,500
init_reject(name)
char *name;
{
! mktemp(name);
rejfp = fopen(name,"w");
if (rejfp == Nullfp)
fatal("patch: can't create %s.\n",name);
--- 498,508 -----
init_reject(name)
char *name;
{
! static int iflag = 0;
! if (!iflag) {
! mktemp(name);
! iflag++;
! }
rejfp = fopen(name,"w");
if (rejfp == Nullfp)
fatal("patch: can't create %s.\n",name);
More information about the Comp.sources.bugs
mailing list