dan@rna.UUCP (Dan Ts'o) (11/25/84)
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);
ekrell@ucla-cs.UUCP (11/26/84)
In article <320@rna.UUCP> dan@rna.UUCP (Dan Ts'o) writes: > > 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. Here's the fix for that problem (The last pointer of i_ptr was pointing to garbage): *** patch.c Sun Nov 25 17:41:58 1984 --- patch.c.new Sun Nov 25 22:53:08 1984 *************** *** 750,756 iline = 1; i_ptr[iline] = i_womp; ! for (s=i_womp; *s; s++) { if (*s == '\n') i_ptr[++iline] = s+1; /* these are NOT null terminated */ } --- 750,756 ----- iline = 1; i_ptr[iline] = i_womp; ! for (s=i_womp; *(s+1); s++) { if (*s == '\n') i_ptr[++iline] = s+1; /* these are NOT null terminated */ } *************** *** 754,760 if (*s == '\n') i_ptr[++iline] = s+1; /* these are NOT null terminated */ } ! input_lines = iline - 1; /* now check for revision, if any */ --- 754,760 ----- if (*s == '\n') i_ptr[++iline] = s+1; /* these are NOT null terminated */ } ! input_lines = iline; /* now check for revision, if any */ -- Eduardo Krell UCLA Computer Science Department ekrell@ucla-locus.arpa ..!{sdcrdcf,ihnp4,trwspp,ucbvax}!ucla-cs!ekrell
bsa@ncoast.UUCP (Brandon Allbery) (11/28/84)
i have yet to get patch running. it runs out of space
(or so malloc() says) as soon as it starts to read the
first hunk into memory.
any ideas what this might mean?
--bsa
--
Brandon Allbery @ North Coast Xenix | the.world!ucbvax!decvax!cwruecmp!
6504 Chestnut Road, Independence, Ohio | {atvax!}ncoast!{tdi1!}bsa
(216) 524-1416 \ 44131 | E1439@CSUOHIO.BITNET (friend's acct.)
| BALLBERY (161-7070) on MCI Mail
---------------------------------------+---------------------------------------
``Kai Fedegon!'' :-}