mirror of
https://gitlab.nic.cz/knot/knot-dns.git
synced 2026-05-28 04:02:31 -04:00
zscanner: bugfix: buffering from pipe
This commit is contained in:
parent
c8b8e00bbc
commit
3cc6da022b
3 changed files with 18 additions and 6 deletions
|
|
@ -227,8 +227,12 @@ static char *read_file_to_buf(
|
|||
char *buf = malloc(bufs + newbufs);
|
||||
int ret = 0;
|
||||
|
||||
while (buf != NULL && (ret = read(fd, buf + bufs, newbufs)) == newbufs) {
|
||||
bufs += newbufs;
|
||||
while (buf != NULL && (ret = read(fd, buf + bufs, newbufs)) > 0) {
|
||||
bufs += ret;
|
||||
if (ret < newbufs) {
|
||||
newbufs -= ret;
|
||||
continue;
|
||||
}
|
||||
newbufs = bufs;
|
||||
char *newbuf = realloc(buf, bufs + newbufs);
|
||||
if (newbuf == NULL) {
|
||||
|
|
|
|||
|
|
@ -6622,8 +6622,12 @@ static char *read_file_to_buf(
|
|||
char *buf = malloc(bufs + newbufs);
|
||||
int ret = 0;
|
||||
|
||||
while (buf != NULL && (ret = read(fd, buf + bufs, newbufs)) == newbufs) {
|
||||
bufs += newbufs;
|
||||
while (buf != NULL && (ret = read(fd, buf + bufs, newbufs)) > 0) {
|
||||
bufs += ret;
|
||||
if (ret < newbufs) {
|
||||
newbufs -= ret;
|
||||
continue;
|
||||
}
|
||||
newbufs = bufs;
|
||||
char *newbuf = realloc(buf, bufs + newbufs);
|
||||
if (newbuf == NULL) {
|
||||
|
|
|
|||
|
|
@ -228,8 +228,12 @@ static char *read_file_to_buf(
|
|||
char *buf = malloc(bufs + newbufs);
|
||||
int ret = 0;
|
||||
|
||||
while (buf != NULL && (ret = read(fd, buf + bufs, newbufs)) == newbufs) {
|
||||
bufs += newbufs;
|
||||
while (buf != NULL && (ret = read(fd, buf + bufs, newbufs)) > 0) {
|
||||
bufs += ret;
|
||||
if (ret < newbufs) {
|
||||
newbufs -= ret;
|
||||
continue;
|
||||
}
|
||||
newbufs = bufs;
|
||||
char *newbuf = realloc(buf, bufs + newbufs);
|
||||
if (newbuf == NULL) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue