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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
|
Index: boa-0.94.14rc21/src/boa.h
===================================================================
--- boa-0.94.14rc21.orig/src/boa.h 2007-11-03 00:51:46.000000000 -0400
+++ boa-0.94.14rc21/src/boa.h 2007-11-03 01:05:20.000000000 -0400
@@ -25,7 +25,9 @@
#ifndef _BOA_H
#define _BOA_H
+/* Important, include before anything else */
#include "config.h"
+
#include <errno.h>
#include <stdlib.h> /* malloc, free, etc. */
#include <stdio.h> /* stdin, stdout, stderr */
@@ -165,7 +167,7 @@
void clean_pathname(char *pathname);
char *get_commonlog_time(void);
void rfc822_time_buf(char *buf, time_t s);
-char *simple_itoa(unsigned int i);
+char *simple_itoa(uint64_t i);
int boa_atoi(const char *s);
int month2int(const char *month);
int modified_since(time_t * mtime, const char *if_modified_since);
Index: boa-0.94.14rc21/src/buffer.c
===================================================================
--- boa-0.94.14rc21.orig/src/buffer.c 2007-11-03 00:51:46.000000000 -0400
+++ boa-0.94.14rc21/src/buffer.c 2007-11-03 01:05:20.000000000 -0400
@@ -212,7 +212,7 @@
return -2;
if (bytes_to_write) {
- int bytes_written;
+ off_t bytes_written;
bytes_written = write(req->fd, req->buffer + req->buffer_start,
bytes_to_write);
Index: boa-0.94.14rc21/src/config.h.in
===================================================================
--- boa-0.94.14rc21.orig/src/config.h.in 2007-11-03 00:51:46.000000000 -0400
+++ boa-0.94.14rc21/src/config.h.in 2007-11-03 01:08:36.000000000 -0400
@@ -205,3 +205,16 @@
/* Define to `int' if <sys/types.h> doesn't define. */
#undef uid_t
+
+/* Those enable the LFS ready structures in the system headers */
+#define _FILE_OFFSET_BITS 64 /* glibc style */
+#define _LARGEFILE_SOURCE 1 /* To make ftello() visible (HP-UX 10.20). */
+#define _LARGE_FILES 1 /* Large file defined on AIX-style hosts. */
+
+#define _LARGEFILE64_SOURCE /* tell kernel headers to provide the O_LARGEFILE value */
+
+#if __WORDSIZE == 64
+#define PRINTF_OFF_T_ARG "%ld"
+#elif __WORDSIZE == 32
+#define PRINTF_OFF_T_ARG "%lld"
+#endif
Index: boa-0.94.14rc21/src/get.c
===================================================================
--- boa-0.94.14rc21.orig/src/get.c 2007-11-03 00:51:46.000000000 -0400
+++ boa-0.94.14rc21/src/get.c 2007-11-03 01:08:20.000000000 -0400
@@ -25,6 +25,10 @@
#include "boa.h"
#include "access.h"
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
#define STR(s) __STR(s)
#define __STR(s) #s
@@ -52,9 +56,9 @@
{
int data_fd, saved_errno;
struct stat statbuf;
- volatile unsigned int bytes_free;
+ volatile off_t bytes_free;
- data_fd = open(req->pathname, O_RDONLY);
+ data_fd = open(req->pathname, O_RDONLY|O_LARGEFILE);
saved_errno = errno; /* might not get used */
#ifdef GUNZIP
@@ -76,7 +80,7 @@
memcpy(gzip_pathname, req->pathname, len);
memcpy(gzip_pathname + len, ".gz", 3);
gzip_pathname[len + 3] = '\0';
- data_fd = open(gzip_pathname, O_RDONLY);
+ data_fd = open(gzip_pathname, O_RDONLY|O_LARGEFILE);
if (data_fd != -1) {
close(data_fd);
@@ -430,8 +434,8 @@
int process_get(request * req)
{
- int bytes_written;
- volatile unsigned int bytes_to_write;
+ off_t bytes_written;
+ volatile off_t bytes_to_write;
if (req->method == M_HEAD) {
return complete_response(req);
@@ -531,7 +535,7 @@
memcpy(pathname_with_index, req->pathname, l1); /* doesn't copy NUL */
memcpy(pathname_with_index + l1, directory_index, l2 + 1); /* does */
- data_fd = open(pathname_with_index, O_RDONLY);
+ data_fd = open(pathname_with_index, O_RDONLY|O_LARGEFILE);
if (data_fd != -1) { /* user's index file */
/* We have to assume that directory_index will fit, because
@@ -555,7 +559,7 @@
* try index.html.gz
*/
strcat(pathname_with_index, ".gz");
- data_fd = open(pathname_with_index, O_RDONLY);
+ data_fd = open(pathname_with_index, O_RDONLY|O_LARGEFILE);
if (data_fd != -1) { /* user's index file */
close(data_fd);
@@ -624,9 +628,9 @@
* include the NUL when calculating if the size is enough
*/
snprintf(pathname_with_index, sizeof(pathname_with_index),
- "%s/dir.%d.%ld", cachedir,
+ "%s/dir.%d." PRINTF_OFF_T_ARG, cachedir,
(int) statbuf->st_dev, statbuf->st_ino);
- data_fd = open(pathname_with_index, O_RDONLY);
+ data_fd = open(pathname_with_index, O_RDONLY|O_LARGEFILE);
if (data_fd != -1) { /* index cache */
@@ -642,7 +646,7 @@
if (index_directory(req, pathname_with_index) == -1)
return -1;
- data_fd = open(pathname_with_index, O_RDONLY); /* Last chance */
+ data_fd = open(pathname_with_index, O_RDONLY|O_LARGEFILE); /* Last chance */
if (data_fd != -1) {
strcpy(req->request_uri, directory_index); /* for mimetype */
fstat(data_fd, statbuf);
@@ -671,7 +675,7 @@
DIR *request_dir;
FILE *fdstream;
struct dirent *dirbuf;
- int bytes = 0;
+ off_t bytes = 0;
char *escname = NULL;
if (chdir(req->pathname) == -1) {
Index: boa-0.94.14rc21/src/globals.h
===================================================================
--- boa-0.94.14rc21.orig/src/globals.h 2007-11-03 00:51:46.000000000 -0400
+++ boa-0.94.14rc21/src/globals.h 2007-11-03 01:05:20.000000000 -0400
@@ -130,9 +130,9 @@
int numranges;
int data_fd; /* fd of data */
- unsigned long filesize; /* filesize */
- unsigned long filepos; /* position in file */
- unsigned long bytes_written; /* total bytes written (sans header) */
+ off_t filesize; /* filesize */
+ off_t filepos; /* position in file */
+ size_t bytes_written; /* total bytes written (sans header) */
char *data_mem; /* mmapped/malloced char array */
char *logline; /* line to log file */
Index: boa-0.94.14rc21/src/index_dir.c
===================================================================
--- boa-0.94.14rc21.orig/src/index_dir.c 2007-11-03 00:51:46.000000000 -0400
+++ boa-0.94.14rc21/src/index_dir.c 2007-11-03 01:08:11.000000000 -0400
@@ -19,6 +19,7 @@
/* $Id: index_dir.c,v 1.32.2.7 2005/02/22 03:00:24 jnelson Exp $*/
+#include "config.h"
#include <stdio.h>
#include <sys/stat.h>
#include <limits.h> /* for PATH_MAX */
@@ -266,10 +267,12 @@
printf("<tr>"
"<td width=\"40%%\"><a href=\"%s/\">%s/</a></td>"
"<td align=right>%s</td>"
- "<td align=right>%ld bytes</td>"
+ "<td align=right>"
+ PRINTF_OFF_T_ARG
+ " bytes</td>"
"</tr>\n",
escaped_filename, html_filename,
- ctime(&statbuf.st_mtime), (long) statbuf.st_size);
+ ctime(&statbuf.st_mtime), (off_t) statbuf.st_size);
}
printf
@@ -312,10 +315,12 @@
"<td width=\"40%%\"><a href=\"%s\">%s</a> "
"<a href=\"%s.gz\">(.gz)</a></td>"
"<td align=right>%s</td>"
- "<td align=right>%ld bytes</td>"
+ "<td align=right>"
+ PRINTF_OFF_T_ARG
+ "bytes</td>"
"</tr>\n",
escaped_filename, html_filename, http_filename,
- ctime(&statbuf.st_mtime), (long) statbuf.st_size);
+ ctime(&statbuf.st_mtime), (off_t) statbuf.st_size);
} else {
#endif
if (html_escape_string(http_filename, escaped_filename,
@@ -326,10 +331,12 @@
printf("<tr>"
"<td width=\"40%%\"><a href=\"%s\">%s</a></td>"
"<td align=right>%s</td>"
- "<td align=right>%ld bytes</td>"
+ "<td align=right>"
+ PRINTF_OFF_T_ARG
+ "bytes</td>"
"</tr>\n",
escaped_filename, html_filename,
- ctime(&statbuf.st_mtime), (long) statbuf.st_size);
+ ctime(&statbuf.st_mtime), (off_t) statbuf.st_size);
#ifdef GUNZIP
}
#endif
Index: boa-0.94.14rc21/src/log.c
===================================================================
--- boa-0.94.14rc21.orig/src/log.c 2007-11-03 00:51:46.000000000 -0400
+++ boa-0.94.14rc21/src/log.c 2007-11-03 01:05:20.000000000 -0400
@@ -146,7 +146,7 @@
} else if (vhost_root) {
printf("%s ", (req->host ? req->host : "(null)"));
}
- printf("%s - - %s\"%s\" %d %ld \"%s\" \"%s\"\n",
+ printf("%s - - %s\"%s\" %d %zu \"%s\" \"%s\"\n",
req->remote_ip_addr,
get_commonlog_time(),
req->logline ? req->logline : "-",
Index: boa-0.94.14rc21/src/mmap_cache.c
===================================================================
--- boa-0.94.14rc21.orig/src/mmap_cache.c 2007-11-03 00:51:46.000000000 -0400
+++ boa-0.94.14rc21/src/mmap_cache.c 2007-11-03 01:05:20.000000000 -0400
@@ -140,7 +140,7 @@
int data_fd;
struct stat statbuf;
struct mmap_entry *e;
- data_fd = open(fname, O_RDONLY);
+ data_fd = open(fname, O_RDONLY|O_LARGEFILE);
if (data_fd == -1) {
perror(fname);
return NULL;
Index: boa-0.94.14rc21/src/pipe.c
===================================================================
--- boa-0.94.14rc21.orig/src/pipe.c 2007-11-03 01:05:20.000000000 -0400
+++ boa-0.94.14rc21/src/pipe.c 2007-11-03 01:05:20.000000000 -0400
@@ -37,8 +37,8 @@
int read_from_pipe(request * req)
{
- int bytes_read; /* signed */
- unsigned int bytes_to_read; /* unsigned */
+ off_t bytes_read; /* signed */
+ off_t bytes_to_read; /* unsigned */ /* XXX really? */
bytes_to_read = BUFFER_SIZE - (req->header_end - req->buffer - 1);
@@ -128,8 +128,8 @@
int write_from_pipe(request * req)
{
- int bytes_written;
- size_t bytes_to_write = req->header_end - req->header_line;
+ off_t bytes_written;
+ off_t bytes_to_write = req->header_end - req->header_line;
if (bytes_to_write == 0) {
if (req->cgi_status == CGI_DONE)
@@ -170,9 +170,9 @@
#ifdef HAVE_SENDFILE
int io_shuffle_sendfile(request * req)
{
- int bytes_written;
- size_t bytes_to_write;
off_t sendfile_offset;
+ off_t bytes_written;
+ off_t bytes_to_write;
if (req->method == M_HEAD) {
return complete_response(req);
@@ -266,8 +266,8 @@
int io_shuffle(request * req)
{
- int bytes_to_read;
- int bytes_written, bytes_to_write;
+ off_t bytes_to_read;
+ off_t bytes_written, bytes_to_write;
if (req->method == M_HEAD) {
return complete_response(req);
@@ -287,7 +287,7 @@
bytes_to_read = bytes_to_write;
if (bytes_to_read > 0 && req->data_fd) {
- int bytes_read;
+ off_t bytes_read;
off_t temp;
temp = lseek(req->data_fd, req->ranges->start, SEEK_SET);
Index: boa-0.94.14rc21/src/range.c
===================================================================
--- boa-0.94.14rc21.orig/src/range.c 2007-11-03 00:51:46.000000000 -0400
+++ boa-0.94.14rc21/src/range.c 2007-11-03 01:05:20.000000000 -0400
@@ -147,7 +147,7 @@
* 5) start > stop && start != -1 :: invalid
*/
DEBUG(DEBUG_RANGE) {
- fprintf(stderr, "range.c: ranges_fixup: %lu-%lu\n", r->start, r->stop);
+ fprintf(stderr, "range.c: ranges_fixup: %lu - %lu\n", r->start, r->stop);
}
/* no stop range specified or stop is too big.
Index: boa-0.94.14rc21/src/read.c
===================================================================
--- boa-0.94.14rc21.orig/src/read.c 2007-11-03 00:51:46.000000000 -0400
+++ boa-0.94.14rc21/src/read.c 2007-11-03 01:05:20.000000000 -0400
@@ -38,7 +38,7 @@
int read_header(request * req)
{
- int bytes;
+ off_t bytes;
char *check, *buffer;
unsigned char uc;
@@ -179,7 +179,7 @@
*/
if (req->content_length) {
- int content_length;
+ off_t content_length;
content_length = boa_atoi(req->content_length);
/* Is a content-length of 0 legal? */
@@ -195,7 +195,7 @@
&& content_length > single_post_limit) {
log_error_doc(req);
fprintf(stderr,
- "Content-Length [%d] > SinglePostLimit [%d] on POST!\n",
+ "Content-Length [" PRINTF_OFF_T_ARG "] > SinglePostLimit [%d] on POST!\n",
content_length, single_post_limit);
send_r_bad_request(req);
return 0;
@@ -224,7 +224,7 @@
if (req->status < BODY_READ) {
/* only reached if request is split across more than one packet */
- unsigned int buf_bytes_left;
+ off_t buf_bytes_left;
buf_bytes_left = CLIENT_STREAM_SIZE - req->client_stream_pos;
if (buf_bytes_left < 1 || buf_bytes_left > CLIENT_STREAM_SIZE) {
@@ -273,7 +273,7 @@
DEBUG(DEBUG_HEADER_READ) {
log_error_time();
req->client_stream[req->client_stream_pos] = '\0';
- fprintf(stderr, "%s:%d -- We read %d bytes: \"%s\"\n",
+ fprintf(stderr, "%s:%d -- We read " PRINTF_OFF_T_ARG " bytes: \"%s\"\n",
__FILE__, __LINE__, bytes,
#ifdef VERY_FASCIST_LOGGING2
req->client_stream + req->client_stream_pos - bytes
@@ -309,8 +309,8 @@
int read_body(request * req)
{
- int bytes_read;
- unsigned int bytes_to_read, bytes_free;
+ off_t bytes_read;
+ off_t bytes_to_read, bytes_free;
bytes_free = BUFFER_SIZE - (req->header_end - req->header_line);
bytes_to_read = req->filesize - req->filepos;
@@ -367,8 +367,8 @@
int write_body(request * req)
{
- int bytes_written;
- unsigned int bytes_to_write = req->header_end - req->header_line;
+ off_t bytes_written;
+ off_t bytes_to_write = req->header_end - req->header_line;
if (req->filepos + bytes_to_write > req->filesize)
bytes_to_write = req->filesize - req->filepos;
@@ -402,7 +402,7 @@
}
DEBUG(DEBUG_HEADER_READ) {
log_error_time();
- fprintf(stderr, "%s:%d - wrote %d bytes of CGI body. %ld of %ld\n",
+ fprintf(stderr, "%s:%d - wrote " PRINTF_OFF_T_ARG " bytes of CGI body. " PRINTF_OFF_T_ARG " of " PRINTF_OFF_T_ARG "\n",
__FILE__, __LINE__,
bytes_written, req->filepos, req->filesize);
}
@@ -417,7 +417,7 @@
req->header_line[bytes_written] = '\0';
fprintf(stderr,
- "%s:%d - wrote %d bytes (%s). %lu of %lu\n",
+ "%s:%d - wrote " PRINTF_OFF_T_ARG " bytes (%s). " PRINTF_OFF_T_ARG " of " PRINTF_OFF_T_ARG "\n",
__FILE__, __LINE__, bytes_written,
req->header_line, req->filepos, req->filesize);
req->header_line[bytes_written] = c;
Index: boa-0.94.14rc21/src/request.c
===================================================================
--- boa-0.94.14rc21.orig/src/request.c 2007-11-03 00:51:46.000000000 -0400
+++ boa-0.94.14rc21/src/request.c 2007-11-03 01:05:20.000000000 -0400
@@ -259,14 +259,14 @@
static void sanitize_request(request * req, int new_req)
{
- static unsigned int bytes_to_zero = offsetof(request, fd);
+ static off_t bytes_to_zero = offsetof(request, fd);
if (new_req) {
req->kacount = ka_max;
req->time_last = current_time;
req->client_stream_pos = 0;
} else {
- unsigned int bytes_to_move =
+ off_t bytes_to_move =
req->client_stream_pos - req->parse_pos;
if (bytes_to_move) {
@@ -282,7 +282,7 @@
DEBUG(DEBUG_REQUEST) {
log_error_time();
- fprintf(stderr, "req: %p, offset: %u\n", (void *) req,
+ fprintf(stderr, "req: %p, offset: " PRINTF_OFF_T_ARG "\n", (void *) req,
bytes_to_zero);
}
Index: boa-0.94.14rc21/src/util.c
===================================================================
--- boa-0.94.14rc21.orig/src/util.c 2007-11-03 01:05:20.000000000 -0400
+++ boa-0.94.14rc21/src/util.c 2007-11-03 01:05:20.000000000 -0400
@@ -497,7 +497,7 @@
memcpy(p, day_tab + t->tm_wday * 4, 4);
}
-char *simple_itoa(unsigned int i)
+char *simple_itoa(uint64_t i)
{
/* 21 digits plus null terminator, good for 64-bit or smaller ints
* for bigger ints, use a bigger buffer!
|