summary refs log tree commit diff
path: root/url.c
diff options
context:
space:
mode:
authorC. McEnroe2020-02-16 23:05:43 -0500
committerC. McEnroe2020-02-16 23:05:43 -0500
commitb20be7cbad775ec2119e022ed8e4d225a488c90c (patch)
treecaba6234d7027c5d2090f6482c23f5411abef3eb /url.c
parentba524ed8045ea0e14664a64790fee53dd72a4541 (diff)
Various small cleanups
Haven't really gone through ui.c yet.
Diffstat (limited to 'url.c')
-rw-r--r--url.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/url.c b/url.c
index 64fdd8b..949f860 100644
--- a/url.c
+++ b/url.c
@@ -17,6 +17,7 @@
 #include <assert.h>
 #include <err.h>
 #include <errno.h>
+#include <limits.h>
 #include <regex.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -142,8 +143,10 @@ static void urlCopy(const char *url) {
 	int error = pipe(rw);
 	if (error) err(EX_OSERR, "pipe");
 
-	ssize_t len = write(rw[1], url, strlen(url));
-	if (len < 0) err(EX_IOERR, "write");
+	size_t len = strlen(url);
+	if (len > PIPE_BUF) len = PIPE_BUF;
+	ssize_t n = write(rw[1], url, len);
+	if (n < 0) err(EX_IOERR, "write");
 
 	error = close(rw[1]);
 	if (error) err(EX_IOERR, "close");