X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=netatalk.git;a=blobdiff_plain;f=libatalk%2Fdsi%2Fdsi_stream.c;h=711a037b5098925c59c77198bb6350d390d9b5a3;hp=79b52c1445b27f3cc1f92a6d00787862df831f5c;hb=8e5e83dac34cf886996821a51dee5c971e7c51f2;hpb=5e33f90c6e08503408178d4e17797ea62da8b170 diff --git a/libatalk/dsi/dsi_stream.c b/libatalk/dsi/dsi_stream.c index 79b52c14..711a037b 100644 --- a/libatalk/dsi/dsi_stream.c +++ b/libatalk/dsi/dsi_stream.c @@ -364,7 +364,9 @@ ssize_t dsi_stream_read_file(DSI *dsi, const int fromfd, off_t offset, const siz sfvcnt = 2; vec[0].sfv_fd = SFV_FD_SELF; vec[0].sfv_flag = 0; - vec[0].sfv_off = block; + /* Cast to unsigned long to prevent sign extension of the + * pointer value for the LFS case; see Apache PR 39463. */ + vec[0].sfv_off = (unsigned long)block; vec[0].sfv_len = DSI_BLOCKSIZ; vec[1].sfv_fd = fromfd; vec[1].sfv_flag = 0; @@ -385,19 +387,20 @@ ssize_t dsi_stream_read_file(DSI *dsi, const int fromfd, off_t offset, const siz switch (errno) { case EINTR: case EAGAIN: -#if defined(SOLARIS) || defined(FREEBSD) + len = 0; #ifdef HAVE_SENDFILEV len = (size_t)nwritten; #else +#if defined(SOLARIS) || defined(FREEBSD) if (pos > offset) { /* we actually have sent sth., adjust counters and keep trying */ len = pos - offset; - written += len; offset = pos; } -#endif /* HAVE_SENDFILEV */ #endif /* defined(SOLARIS) || defined(FREEBSD) */ - if (dsi_peek(dsi)) { +#endif /* HAVE_SENDFILEV */ + + if (dsi_peek(dsi) != 0) { ret = -1; goto exit; } @@ -424,7 +427,7 @@ ssize_t dsi_stream_read_file(DSI *dsi, const int fromfd, off_t offset, const siz vec[0].sfv_len -= len; } #endif /* HAVE_SENDFILEV */ - + LOG(log_maxdebug, logtype_dsi, "dsi_stream_read_file: wrote: %zd", len); written += len; } #ifdef HAVE_SENDFILEV @@ -530,7 +533,7 @@ int dsi_stream_send(DSI *dsi, void *buf, size_t length) break; else if (len < 0) { /* error */ if (errno == EAGAIN || errno == EWOULDBLOCK) { - if (!dsi_peek(dsi)) { + if (dsi_peek(dsi) == 0) { continue; } } @@ -593,7 +596,7 @@ int dsi_stream_receive(DSI *dsi) dsi->clientID = ntohs(dsi->header.dsi_requestID); /* make sure we don't over-write our buffers. */ - dsi->cmdlen = MIN(ntohl(dsi->header.dsi_len), DSI_CMDSIZ); + dsi->cmdlen = MIN(ntohl(dsi->header.dsi_len), dsi->server_quantum); if (dsi_stream_read(dsi, dsi->commands, dsi->cmdlen) != dsi->cmdlen) return 0;