[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [libmicrohttpd] bug in MHD_create_response_from_fd_at_offset()
From: |
Christian Grothoff |
Subject: |
Re: [libmicrohttpd] bug in MHD_create_response_from_fd_at_offset() |
Date: |
Fri, 11 Mar 2011 22:28:00 +0100 |
User-agent: |
KMail/1.13.5 (Linux/2.6.35-27-generic; KDE/4.5.1; i686; ; ) |
You're right, my interpretation of "total_size" was wrong (it is just the
total size of the response, not (necessarily) the total size of the file).
Fixed in SVN 14633.
-Christian
On Friday, March 11, 2011 09:32:21 pm Eivind Sarto wrote:
> There appears to be a bug in MHD_create_response_from_fd_at_offset().
> Calling this function with anything other than a zero offset will cause
> wrong data or no data (sendfile fails if length < 0).
>
> If you use this call with any application that uses ranges, this bug will
> trigger.
>
> In src/daemon/daemon.c: send_param_adapter()
> .....
> /* can use sendfile */
> offset = (off_t) connection->response_write_position +
> connection->response->fd_off; #ifdef BUGFIX
> /* correct */
> left = connection->response->total_size -
> connection->response_write_position; #else
> left = connection->response->total_size - offset;
> #endif
> if (left > SSIZE_MAX)
> left = SSIZE_MAX; /* cap at return value limit */
> ret = sendfile (connection->socket_fd,
> fd,
> &offset,
> left);
>
>
> -eivind