summaryrefslogtreecommitdiff
path: root/lib/libpthread
diff options
context:
space:
mode:
authorFederico G. Schwindt <fgsch@cvs.openbsd.org>2001-08-11 14:56:08 +0000
committerFederico G. Schwindt <fgsch@cvs.openbsd.org>2001-08-11 14:56:08 +0000
commit55a744f852df69ec59a78b0045492d9bdf87306f (patch)
tree82e19a22182ababb39a35cfee1fe7eefb80ac4ce /lib/libpthread
parentb7d10a986fcd6d83d5e1febbc145b267b8f7152c (diff)
Avoid an infinite loop if the last iov_len is 0; from FreeBSD.
Diffstat (limited to 'lib/libpthread')
-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;
+ }
}
/*