summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjulien.pierre.boogz%sun.com <devnull@localhost>2008-05-16 02:16:02 +0000
committerjulien.pierre.boogz%sun.com <devnull@localhost>2008-05-16 02:16:02 +0000
commiteec85ea5f82573e1bb5b12dc933d801183df56b6 (patch)
tree0e4489fd852a62f03b2be6f13f2dc119f47cd72f
parent3e3f889964d8a15ba04e3a0e3085e6d6d89db5d2 (diff)
downloadnspr-hg-eec85ea5f82573e1bb5b12dc933d801183df56b6.tar.gz
Fix for bug 266215 . Add conversion code and assertions for iovec. r=wtc
-rw-r--r--pr/src/md/beos/bnet.c16
-rw-r--r--pr/src/md/os2/os2sock.c16
2 files changed, 30 insertions, 2 deletions
diff --git a/pr/src/md/beos/bnet.c b/pr/src/md/beos/bnet.c
index 9b10509e..d0975ed4 100644
--- a/pr/src/md/beos/bnet.c
+++ b/pr/src/md/beos/bnet.c
@@ -439,6 +439,20 @@ PRInt32 _MD_writev(
PRThread *me = _PR_MD_CURRENT_THREAD();
PRInt32 index, amount = 0;
PRInt32 osfd = fd->secret->md.osfd;
+ struct iovec osiov[PR_MAX_IOVECTOR_SIZE];
+
+ /* Ensured by PR_Writev */
+ PR_ASSERT(iov_size <= PR_MAX_IOVECTOR_SIZE);
+
+ /*
+ * We can't pass iov to writev because PRIOVec and struct iovec
+ * may not be binary compatible. Make osiov a copy of iov and
+ * pass osiov to writev.
+ */
+ for (index = 0; index < iov_size; index++) {
+ osiov[index].iov_base = iov[index].iov_base;
+ osiov[index].iov_len = iov[index].iov_len;
+ }
/*
* Calculate the total number of bytes to be sent; needed for
@@ -453,7 +467,7 @@ PRInt32 _MD_writev(
}
}
- while ((rv = writev(osfd, (const struct iovec*)iov, iov_size)) == -1) {
+ while ((rv = writev(osfd, osiov, iov_size)) == -1) {
err = _MD_ERRNO();
if ((err == EAGAIN) || (err == EWOULDBLOCK)) {
if (fd->secret->nonblocking) {
diff --git a/pr/src/md/os2/os2sock.c b/pr/src/md/os2/os2sock.c
index ce002318..6a7e3dc2 100644
--- a/pr/src/md/os2/os2sock.c
+++ b/pr/src/md/os2/os2sock.c
@@ -523,6 +523,20 @@ _PR_MD_WRITEV(PRFileDesc *fd, const PRIOVec *iov, PRInt32 iov_size,
PRThread *me = _PR_MD_CURRENT_THREAD();
PRInt32 index, amount = 0;
PRInt32 osfd = fd->secret->md.osfd;
+ struct iovec osiov[PR_MAX_IOVECTOR_SIZE];
+
+ /* Ensured by PR_Writev */
+ PR_ASSERT(iov_size <= PR_MAX_IOVECTOR_SIZE);
+
+ /*
+ * We can't pass iov to so_writev because PRIOVec and struct iovec
+ * may not be binary compatible. Make osiov a copy of iov and
+ * pass osiov to so_writev .
+ */
+ for (index = 0; index < iov_size; index++) {
+ osiov[index].iov_base = iov[index].iov_base;
+ osiov[index].iov_len = iov[index].iov_len;
+ }
/*
* Calculate the total number of bytes to be sent; needed for
@@ -537,7 +551,7 @@ _PR_MD_WRITEV(PRFileDesc *fd, const PRIOVec *iov, PRInt32 iov_size,
}
}
- while ((rv = so_writev(osfd, (const struct iovec*)iov, iov_size)) == -1) {
+ while ((rv = so_writev(osfd, osiov, iov_size)) == -1) {
err = sock_errno();
if ((err == EWOULDBLOCK)) {
if (fd->secret->nonblocking) {