summaryrefslogtreecommitdiffstats
path: root/lib/libpthread/uthread
diff options
context:
space:
mode:
authorfgsch <fgsch@openbsd.org>2001-08-11 14:56:07 +0000
committerfgsch <fgsch@openbsd.org>2001-08-11 14:56:07 +0000
commit94ec0ab3c0c38236472e45a6dbb2e2bff58d6d30 (patch)
tree00880576d679f1d1981c68e4ad1dc2f926c59d4d /lib/libpthread/uthread
parentAdd support for ICMP errors referring to ICMP queries/replies. Fixes (diff)
downloadwireguard-openbsd-94ec0ab3c0c38236472e45a6dbb2e2bff58d6d30.tar.xz
wireguard-openbsd-94ec0ab3c0c38236472e45a6dbb2e2bff58d6d30.zip
Avoid an infinite loop if the last iov_len is 0; from FreeBSD.
Diffstat (limited to 'lib/libpthread/uthread')
-rw-r--r--lib/libpthread/uthread/uthread_writev.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/libpthread/uthread/uthread_writev.c b/lib/libpthread/uthread/uthread_writev.c
index 411b3bc0238..be26356d2c9 100644
--- a/lib/libpthread/uthread/uthread_writev.c
+++ b/lib/libpthread/uthread/uthread_writev.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uthread_writev.c,v 1.3 1999/11/25 07:01:47 d Exp $ */
+/* $OpenBSD: uthread_writev.c,v 1.4 2001/08/11 14:56:07 fgsch Exp $ */
/*
* Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
* All rights reserved.
@@ -137,6 +137,18 @@ 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;
+ }
}
/*