Package: webfs / 1.21+ds1-12

68_large_files.diff Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
Description: Transmission of large files in TLS-mode.
 The legacy signature of ssl_read(), ssl_write() and ssl_blk_write()
 could not represent correctly sizes larger that 2.2GB. An internal
 counter needs to be of type ssize_t.
 .
 Likewise, the type of the byte counter in "struct REQUEST.bc"
 must be adapted.
 .
 The logging entry coded in "webfsd.c" could not record sizes
 above 2.2GB correctly, needing a change of format string.
 .
 Increase the buffer size in ssl_blk_write() to 16 kB for a slightly
 better throughput.
Author: Mats Erik Andersson <debian@gisladisker.se>
Bug-Debian: http://bugs.debian.org/702660
Forwarded: no
Last-Update: 2013-10-22

--- webfs-1.21+ds1.debian/httpd.h
+++ webfs-1.21+ds1/httpd.h
@@ -1,3 +1,4 @@
+#include <sys/types.h>
 #include <sys/stat.h>
 #ifdef USE_THREADS
 # include <pthread.h>
@@ -101,7 +102,7 @@ struct REQUEST {
     
     /* response */
     int         status;              /* status code (log) */
-    int         bc;                  /* byte counter (log) */
+    size_t      bc;                  /* byte counter (log) */
     char	hres[MAX_HEADER+1];  /* response header */
     int	        lres;		     /* header length */
     char        *mime;               /* mime type */
@@ -218,9 +219,9 @@ static void inline close_on_exec(int fd)
 /* --- ssl.c ---------------------------------------------------- */
 
 #if defined(USE_SSL) || defined(USE_GNUTLS)
-extern int ssl_read(struct REQUEST *req, char *buf, int len);
-extern int ssl_write(struct REQUEST *req, char *buf, int len);
-extern int ssl_blk_write(struct REQUEST *req, int offset, int len);
+extern ssize_t ssl_read(struct REQUEST *req, char *buf, size_t len);
+extern ssize_t ssl_write(struct REQUEST *req, char *buf, size_t len);
+extern ssize_t ssl_blk_write(struct REQUEST *req, off_t offset, size_t len);
 extern int init_ssl(void);
 extern int open_ssl_session(struct REQUEST *req);
 #endif
--- webfs-1.21+ds1.debian/ssl.c
+++ webfs-1.21+ds1/ssl.c
@@ -17,9 +17,9 @@
 static pthread_mutex_t lock_ssl = PTHREAD_MUTEX_INITIALIZER;
 #endif
 
-int ssl_read(struct REQUEST *req, char *buf, int len)
+ssize_t ssl_read(struct REQUEST *req, char *buf, size_t len)
 {
-    int rc;
+    ssize_t rc;
 
 #ifdef USE_GNUTLS
     memset(buf, 0, len);
@@ -60,9 +60,9 @@ int ssl_read(struct REQUEST *req, char *buf, int len)
     return rc;
 }
 
-int ssl_write(struct REQUEST *req, char *buf, int len)
+ssize_t ssl_write(struct REQUEST *req, char *buf, size_t len)
 {
-    int rc;
+    ssize_t rc;
 
 #ifdef USE_GNUTLS
     while (1) {
@@ -100,10 +100,10 @@ int ssl_write(struct REQUEST *req, char *buf, int len)
     return rc;
 }
 
-int ssl_blk_write(struct REQUEST *req, int offset, int len)
+ssize_t ssl_blk_write(struct REQUEST *req, off_t offset, size_t len)
 {
-    int  rc;
-    char buf[4096];
+    ssize_t  rc;
+    char buf[4 * 4096];
 
     if (lseek(req->bfd, offset, SEEK_SET) == -1) {
 	if (debug)
@@ -119,7 +119,7 @@ int ssl_blk_write(struct REQUEST *req, int offset, int len)
 	req->state = STATE_CLOSE;
 	return rc;
     }
-    return ssl_write(req, buf, rc);
+    return ssl_write(req, buf, (size_t) rc);
 }
 
 #if defined(USE_SSL) && !defined(USE_GNUTLS)
--- webfs-1.21+ds1.debian/webfsd.c
+++ webfs-1.21+ds1/webfsd.c
@@ -300,12 +300,12 @@ access_log(struct REQUEST *req, time_t now)
     if (0 == req->status)
 	req->status = 400; /* bad request */
     if (400 == req->status) {
-	fprintf(logfh,"%s - - %s \"-\" 400 %d\n",
+	fprintf(logfh,"%s - - %s \"-\" 400 %zd\n",
 		req->peerhost,
 		timestamp,
 		req->bc);
     } else {
-	fprintf(logfh,"%s - - %s \"%s %s HTTP/%d.%d\" %d %d\n",
+	fprintf(logfh,"%s - - %s \"%s %s HTTP/%d.%d\" %d %zd\n",
 		req->peerhost,
 		timestamp,
 		req->type,