summaryrefslogtreecommitdiffstats
path: root/usr.bin/patch/util.c
diff options
context:
space:
mode:
authorjca <jca@openbsd.org>2019-12-02 22:17:32 +0000
committerjca <jca@openbsd.org>2019-12-02 22:17:32 +0000
commit5fbd5e42b6e8a8eb350fdd243f46cfefbc9d0b49 (patch)
treeec65908650d1ed62a7b684ae63306187b0056102 /usr.bin/patch/util.c
parentthe dhcp6 printing doesn't need these files anymore. (diff)
downloadwireguard-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/util.c')
-rw-r--r--usr.bin/patch/util.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/usr.bin/patch/util.c b/usr.bin/patch/util.c
index 0f274825065..f079b5149c5 100644
--- a/usr.bin/patch/util.c
+++ b/usr.bin/patch/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.44 2019/08/17 14:25:06 deraadt Exp $ */
+/* $OpenBSD: util.c,v 1.45 2019/12/02 22:17:32 jca Exp $ */
/*
* patch - a program to apply diffs to original files
@@ -61,7 +61,7 @@ move_file(const char *from, const char *to)
fromfd = open(from, O_RDONLY);
if (fromfd == -1)
pfatal("internal error, can't reopen %s", from);
- while ((i = read(fromfd, buf, sizeof buf)) > 0)
+ while ((i = read(fromfd, buf, bufsz)) > 0)
if (write(STDOUT_FILENO, buf, i) != i)
pfatal("write failed");
close(fromfd);
@@ -160,7 +160,7 @@ copy_file(const char *from, const char *to)
fromfd = open(from, O_RDONLY, 0);
if (fromfd == -1)
pfatal("internal error, can't reopen %s", from);
- while ((i = read(fromfd, buf, sizeof buf)) > 0)
+ while ((i = read(fromfd, buf, bufsz)) > 0)
if (write(tofd, buf, i) != i)
pfatal("write to %s failed", to);
close(fromfd);
@@ -267,7 +267,7 @@ ask(const char *fmt, ...)
if (ttyfd < 0)
ttyfd = open(_PATH_TTY, O_RDONLY);
if (ttyfd >= 0) {
- if ((nr = read(ttyfd, buf, sizeof(buf))) > 0 &&
+ if ((nr = read(ttyfd, buf, bufsz)) > 0 &&
buf[nr - 1] == '\n')
buf[nr - 1] = '\0';
}