Bug in patch

Mark Brader msb at lsuc.UUCP
Fri Mar 1 16:14:37 AEST 1985


There's a bug in Larry Wall's generally lovely utility "patch".
When he's dumping out the lines "leading up to" the context diff,
he passes the lines themselves as formats to fprintf.  This fails if they
are very long or if they contain '%'.

The fix is very simple.

If this message has a long enough news path, you may need to strip off
the netnews header before you can use patch to install the fix, though...

*** patch.c.old	Sat Dec 29 21:10:06 1984
--- patch.c	Fri Mar  1 00:57:44 1985
***************
*** 1165,1171
  	while (ftell(pfp) < file_pos) {
  	    ret = fgets(buf,sizeof buf,pfp);
  	    assert(ret != Nullch);
! 	    say(buf);
  	}
  	say("--------------------------\n");
      }

--- 1165,1171 -----
  	while (ftell(pfp) < file_pos) {
  	    ret = fgets(buf,sizeof buf,pfp);
  	    assert(ret != Nullch);
! 	    say("%s",buf);
  	}
  	say("--------------------------\n");
      }


Mark Brader



More information about the Comp.sources.bugs mailing list