summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorjasone <jasone@FreeBSD.org>1999-12-16 22:35:40 +0000
committerjasone <jasone@FreeBSD.org>1999-12-16 22:35:40 +0000
commit395027ca77cd13f1357538ac7a65a9b527d2beff (patch)
tree8303a0cb98a36909c6bac8d64b37e618e4ac0c73 /lib
parentf9019037baa7dfcb11ab26392ac6ed9b33bf7a83 (diff)
downloadFreeBSD-src-395027ca77cd13f1357538ac7a65a9b527d2beff.zip
FreeBSD-src-395027ca77cd13f1357538ac7a65a9b527d2beff.tar.gz
Avoid an infinite loop if the last element of the iov array passed to
writev() has an iov_len of 0. PR: bin/8281
Diffstat (limited to 'lib')
-rw-r--r--lib/libc_r/uthread/uthread_writev.c14
-rw-r--r--lib/libkse/thread/thr_writev.c14
-rw-r--r--lib/libpthread/thread/thr_writev.c14
3 files changed, 39 insertions, 3 deletions
diff --git a/lib/libc_r/uthread/uthread_writev.c b/lib/libc_r/uthread/uthread_writev.c
index 8ca5db7..375f599 100644
--- a/lib/libc_r/uthread/uthread_writev.c
+++ b/lib/libc_r/uthread/uthread_writev.c
@@ -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
diff --git a/lib/libkse/thread/thr_writev.c b/lib/libkse/thread/thr_writev.c
index 8ca5db7..375f599 100644
--- a/lib/libkse/thread/thr_writev.c
+++ b/lib/libkse/thread/thr_writev.c
@@ -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
diff --git a/lib/libpthread/thread/thr_writev.c b/lib/libpthread/thread/thr_writev.c
index 8ca5db7..375f599 100644
--- a/lib/libpthread/thread/thr_writev.c
+++ b/lib/libpthread/thread/thr_writev.c
@@ -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
OpenPOWER on IntegriCloud