Hi, 

the attached patch for 1.3 fixes the Content-Length header in the 416
"range not satisfiable" response, that shows an overflow with files
larger than 2 GB. 

Note that while this fix "makes it work", there are likely other places
where the incorrect number still shows up, like in the log files.

Details:
 - clength should match the off_t type of st_size, the file size as
   returned with stat(2).
 - Just to be sure, it is casted to AP_LONGEST_LONG before giving it out. 

Peter

-- 
VFS: Busy inodes after unmount. Self-destruct in 5 seconds.  Have a nice day...
diff -ur apache_1.3.19.orig/src/include/http_protocol.h 
apache_1.3.19/src/include/http_protocol.h
--- apache_1.3.19.orig/src/include/http_protocol.h      Mon Jan 15 18:04:35 2001
+++ apache_1.3.19/src/include/http_protocol.h   Mon Apr 16 17:59:00 2001
@@ -113,7 +113,7 @@
  * permit_cache argument is set to one).
  */
 
-API_EXPORT(int) ap_set_content_length(request_rec *r, long length);
+API_EXPORT(int) ap_set_content_length(request_rec *r, off_t length);
 API_EXPORT(int) ap_set_keepalive(request_rec *r);
 API_EXPORT(time_t) ap_rationalize_mtime(request_rec *r, time_t mtime);
 API_EXPORT(char *) ap_make_etag(request_rec *r, int force_weak);
diff -ur apache_1.3.19.orig/src/main/http_protocol.c 
apache_1.3.19/src/main/http_protocol.c
--- apache_1.3.19.orig/src/main/http_protocol.c Fri Feb 16 15:53:24 2001
+++ apache_1.3.19/src/main/http_protocol.c      Mon Apr 16 18:41:53 2001
@@ -406,10 +406,11 @@
     return 0;
 }
 
-API_EXPORT(int) ap_set_content_length(request_rec *r, long clength)
+API_EXPORT(int) ap_set_content_length(request_rec *r, off_t clength)
 {
     r->clength = clength;
-    ap_table_setn(r->headers_out, "Content-Length", ap_psprintf(r->pool, "%ld", 
clength));
+    ap_table_setn(r->headers_out, "Content-Length", ap_psprintf(r->pool, "%qd", 
+(AP_LONGEST_LONG) clength));
+                       /* see src/ap/ap_snprintf.c:787 for the definition of %qd */
     return 0;
 }
 

Reply via email to