Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site rna.UUCP Path: utzoo!linus!philabs!cmcl2!rna!dan From: dan@rna.UUCP (Dan Ts'o) Newsgroups: net.sources.bugs Subject: Patch patch... Message-ID: <320@rna.UUCP> Date: Sat, 24-Nov-84 17:58:51 EST Article-I.D.: rna.320 Posted: Sat Nov 24 17:58:51 1984 Date-Received: Sun, 25-Nov-84 09:11:37 EST Organization: Rockefeller Neurobiology, NYC Lines: 62 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);