Avoid an infinite loop if the last element of the iov array passed to

writev() has an iov_len of 0.

PR:		bin/8281
This commit is contained in:
Jason Evans 1999-12-16 22:35:40 +00:00
parent 6a4152243f
commit e6a5e33c6b
3 changed files with 39 additions and 3 deletions

View File

@ -136,8 +136,20 @@ writev(int fd, const struct iovec * iov, int iovcnt)
cnt = 0;
}
}
}
} else if (n == 0) {
/*
* Avoid an infinite loop if the last iov_len is
* 0.
*/
while (idx < iovcnt && p_iov[idx].iov_len == 0)
idx++;
if (idx == iovcnt) {
ret = num;
break;
}
}
/*
* If performing a blocking write, check if the
* write would have blocked or if some bytes

View File

@ -136,8 +136,20 @@ writev(int fd, const struct iovec * iov, int iovcnt)
cnt = 0;
}
}
}
} else if (n == 0) {
/*
* Avoid an infinite loop if the last iov_len is
* 0.
*/
while (idx < iovcnt && p_iov[idx].iov_len == 0)
idx++;
if (idx == iovcnt) {
ret = num;
break;
}
}
/*
* If performing a blocking write, check if the
* write would have blocked or if some bytes

View File

@ -136,8 +136,20 @@ writev(int fd, const struct iovec * iov, int iovcnt)
cnt = 0;
}
}
}
} else if (n == 0) {
/*
* Avoid an infinite loop if the last iov_len is
* 0.
*/
while (idx < iovcnt && p_iov[idx].iov_len == 0)
idx++;
if (idx == iovcnt) {
ret = num;
break;
}
}
/*
* If performing a blocking write, check if the
* write would have blocked or if some bytes