You are viewing a plain text version of this content. The canonical link for it is here.
Posted to apache-bugdb@apache.org by Ben Reser <br...@regnow.com> on 1997/11/05 23:00:13 UTC

apache-api/1366: send_fd and send_fd_length do not return bytes sent properly

>Number:         1366
>Category:       apache-api
>Synopsis:       send_fd and send_fd_length do not return bytes sent properly
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    apache
>State:          open
>Class:          sw-bug
>Submitter-Id:   apache
>Arrival-Date:   Wed Nov  5 14:10:00 PST 1997
>Last-Modified:
>Originator:     breser@regnow.com
>Organization:
apache
>Release:        All (discovered in Stronghold)
>Environment:
Not terribly important here, this is a logic error in the code.
I've found the problem and describe it and explain how to fix it.
>Description:
The send_fd_lenght function (which send_fd is based off of) does not calculate
total bytes sent in a logical way.

It increments after it reads from the file rather than after it has actually
sent the data.

Thus data that wasn't actually sent will be returned as being sent.

This makes it impossible for a module to detect if a file transfer was completed.
>How-To-Repeat:
You'll have to write an Apache Module.
The one that I was working on when I found this bug is a mod_perl module.
However, mod_perl itself has a bug in the Apache module so that it doesn't
give the return of the send_fd function (ARGHH).  If you'd like instructions
on how to fix this I could send you a very simple module that will show you the
problem.
>Fix:
Yup,

delete the line in send_fd_length (http_protocol.c) that reads:
total_bytes_sent += n;

and replace it with this line at the bottom of the while look that controls
sending the data:
total_bytes_sent += w%3
>Audit-Trail:
>Unformatted: