shithub: riscv

Download patch

ref: fc3c91d91f98a4b19834dc7f3735857da6fbcd01
parent: 94018b213027a9252628e107c202eefc7261073a
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Wed Apr 18 21:00:12 EDT 2018

ndb/dnsquery, ndb/csquery: handle long lines

--- a/sys/src/cmd/ndb/csquery.c
+++ b/sys/src/cmd/ndb/csquery.c
@@ -16,7 +16,7 @@
 void
 query(char *addr)
 {
-	char buf[128];
+	char buf[8192];
 	int fd, n;
 
 	fd = open(server, ORDWR);
@@ -31,10 +31,9 @@
 	}
 	if(!statusonly){
 		seek(fd, 0, 0);
-		while((n = read(fd, buf, sizeof(buf)-1)) > 0){
-			buf[n] = 0;
-			print("%s\n", buf);
-		}
+		while((n = read(fd, buf, sizeof(buf))) > 0)
+			write(1, buf, n);
+		write(1, "\n", 1);
 	}
 	close(fd);
 }
--- a/sys/src/cmd/ndb/dnsquery.c
+++ b/sys/src/cmd/ndb/dnsquery.c
@@ -38,7 +38,7 @@
 static void
 querydns(int fd, char *line, int n)
 {
-	char buf[1024];
+	char buf[8192+1];
 
 	seek(fd, 0, 0);
 	if(write(fd, line, n) != n) {
@@ -46,10 +46,9 @@
 		return;
 	}
 	seek(fd, 0, 0);
-	buf[0] = '\0';
-	while((n = read(fd, buf, sizeof(buf))) > 0){
-		buf[n] = '\0';
-		print("%s\n", buf);
+	while((n = read(fd, buf, sizeof(buf)-1)) > 0){
+		buf[n++] = '\n';
+		write(1, buf, n);
 	}
 }