1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-16 10:20:30 +00:00

Fix an off-by-one error (> where >= should have been used) which caused

_fetch_writev() to incorrectly report EPIPE in certain cases.

Also fix a number of const warnings by using __DECONST(), plus a signed /
unsigned comparison by casting the rhs to ssize_t.

Submitted by:	fenner, Craig Rodrigues <rodrigc@attbi.com>
This commit is contained in:
Dag-Erling Smørgrav 2002-10-28 10:19:03 +00:00
parent 9805beec05
commit 32a4a82829
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=106081

View File

@ -458,7 +458,7 @@ _fetch_write(conn_t *conn, const char *buf, size_t len)
{
struct iovec iov;
iov.iov_base = (char *)buf;
iov.iov_base = __DECONST(char *, buf);
iov.iov_len = len;
return _fetch_writev(conn, &iov, 1);
}
@ -525,15 +525,14 @@ _fetch_writev(conn_t *conn, struct iovec *iov, int iovcnt)
return (-1);
}
total += wlen;
while (iovcnt > 0 && wlen > iov->iov_len) {
while (iovcnt > 0 && wlen >= (ssize_t)iov->iov_len) {
wlen -= iov->iov_len;
iov++;
iovcnt--;
}
if (iovcnt > 0) {
iov->iov_len -= wlen;
iov->iov_base += wlen;
wlen = 0;
iov->iov_base = __DECONST(char *, iov->iov_base) + wlen;
}
}
return (total);
@ -549,9 +548,9 @@ _fetch_putln(conn_t *conn, const char *str, size_t len)
struct iovec iov[2];
DEBUG(fprintf(stderr, ">>> %s\n", str));
iov[0].iov_base = (char *)str;
iov[0].iov_base = __DECONST(char *, str);
iov[0].iov_len = len;
iov[1].iov_base = (char *)ENDL;
iov[1].iov_base = __DECONST(char *, ENDL);
iov[1].iov_len = sizeof ENDL;
if (_fetch_writev(conn, iov, 2) == -1)
return (-1);