diff options
author | 2019-12-02 22:17:32 +0000 | |
---|---|---|
committer | 2019-12-02 22:17:32 +0000 | |
commit | 5fbd5e42b6e8a8eb350fdd243f46cfefbc9d0b49 (patch) | |
tree | ec65908650d1ed62a7b684ae63306187b0056102 /usr.bin/patch/patch.c | |
parent | the dhcp6 printing doesn't need these files anymore. (diff) | |
download | wireguard-openbsd-5fbd5e42b6e8a8eb350fdd243f46cfefbc9d0b49.tar.xz wireguard-openbsd-5fbd5e42b6e8a8eb350fdd243f46cfefbc9d0b49.zip |
Use getline(3) to handle lines longer than 8192 bytes in patch files
Spotted by jsg@ when working on mesa. Diff tested by sthen@ in
a partial i386 bulk. Input from and ok jsg@ millert@
Diffstat (limited to 'usr.bin/patch/patch.c')
-rw-r--r-- | usr.bin/patch/patch.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/usr.bin/patch/patch.c b/usr.bin/patch/patch.c index 89e32667fbf..1d9070b0184 100644 --- a/usr.bin/patch/patch.c +++ b/usr.bin/patch/patch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: patch.c,v 1.68 2019/06/28 13:35:02 deraadt Exp $ */ +/* $OpenBSD: patch.c,v 1.69 2019/12/02 22:17:32 jca Exp $ */ /* * patch - a program to apply diffs to original files @@ -47,7 +47,8 @@ mode_t filemode = 0644; -char buf[MAXLINELEN]; /* general purpose buffer */ +char *buf; /* general purpose buffer */ +size_t bufsz; /* general purpose buffer size */ bool using_plan_a = true; /* try to keep everything in memory */ bool out_of_mem = false; /* ran out of memory in plan a */ @@ -153,6 +154,11 @@ main(int argc, char *argv[]) my_exit(2); } + bufsz = INITLINELEN; + if ((buf = malloc(bufsz)) == NULL) + pfatal("allocating input buffer"); + buf[0] = '\0'; + setvbuf(stdout, NULL, _IOLBF, 0); setvbuf(stderr, NULL, _IOLBF, 0); for (i = 0; i < MAXFILEC; i++) |