From: kettenis Date: Wed, 20 May 2015 09:28:47 +0000 (+0000) Subject: Use off_t instead of size_t to pass file size and print it using %lld when X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=d1cfc522a6e90037d0514da158849c283b0f2e26;p=openbsd Use off_t instead of size_t to pass file size and print it using %lld when constructing the Content-Length header field. Should fix some, but probably not all, problems with serving files bigger than 2G on 32-bit architectures. ok reyk@, florian@ --- diff --git a/usr.sbin/httpd/httpd.h b/usr.sbin/httpd/httpd.h index 50f300a468d..1431eaa2c9e 100644 --- a/usr.sbin/httpd/httpd.h +++ b/usr.sbin/httpd/httpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: httpd.h,v 1.82 2015/03/15 22:08:45 florian Exp $ */ +/* $OpenBSD: httpd.h,v 1.83 2015/05/20 09:28:47 kettenis Exp $ */ /* * Copyright (c) 2006 - 2015 Reyk Floeter @@ -557,7 +557,7 @@ int server_headers(struct client *, void *, int (*)(struct client *, struct kv *, void *), void *); int server_writeresponse_http(struct client *); int server_response_http(struct client *, u_int, struct media_type *, - size_t, time_t); + off_t, time_t); void server_reset_http(struct client *); void server_close_http(struct client *); int server_response(struct httpd *, struct client *); diff --git a/usr.sbin/httpd/server_http.c b/usr.sbin/httpd/server_http.c index 7b65a5e1777..99d52674790 100644 --- a/usr.sbin/httpd/server_http.c +++ b/usr.sbin/httpd/server_http.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server_http.c,v 1.79 2015/05/03 18:39:58 florian Exp $ */ +/* $OpenBSD: server_http.c,v 1.80 2015/05/20 09:28:47 kettenis Exp $ */ /* * Copyright (c) 2006 - 2015 Reyk Floeter @@ -1133,7 +1133,7 @@ server_getlocation(struct client *clt, const char *path) int server_response_http(struct client *clt, u_int code, - struct media_type *media, size_t size, time_t mtime) + struct media_type *media, off_t size, time_t mtime) { struct http_descriptor *desc = clt->clt_descreq; struct http_descriptor *resp = clt->clt_descresp; @@ -1174,7 +1174,7 @@ server_response_http(struct client *clt, u_int code, /* Set content length, if specified */ if ((cl = kv_add(&resp->http_headers, "Content-Length", NULL)) == NULL || - kv_set(cl, "%ld", size) == -1) + kv_set(cl, "%lld", (long long)size) == -1) return (-1); /* Set last modification time */