ndb/dnsquery, ndb/csquery: handle long lines

This commit is contained in:
cinap_lenrek 2018-04-19 01:00:12 +02:00
parent 94018b2130
commit fc3c91d91f
2 changed files with 8 additions and 10 deletions

View file

@ -16,7 +16,7 @@ usage(void)
void
query(char *addr)
{
char buf[128];
char buf[8192];
int fd, n;
fd = open(server, ORDWR);
@ -31,10 +31,9 @@ query(char *addr)
}
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);
}

View file

@ -38,7 +38,7 @@ setup(int argc, char **argv)
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 @@ querydns(int fd, char *line, int n)
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);
}
}