diff options
author | Pierre-Yves Ritschard <pyr@cvs.openbsd.org> | 2010-02-23 08:15:28 +0000 |
---|---|---|
committer | Pierre-Yves Ritschard <pyr@cvs.openbsd.org> | 2010-02-23 08:15:28 +0000 |
commit | 94b5339772392c8b478971d87d45ee719f5ee858 (patch) | |
tree | fbd0b77b5477e3d57a7f5cd9ad38cc3f6d25f76a /usr.sbin | |
parent | 707e79b58dec3644902d83355a2ec7a92443a78e (diff) |
Fix byte range parsing, broken in last revision of http_protocol.c,
unfortunately this backs out the use of strtonum and goes back to strtoll
will need more love in a future diff.
This fix from Dan Harnett <daniel @ harnett . name>
ok deraadt@
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/httpd/src/include/http_protocol.h | 6 | ||||
-rw-r--r-- | usr.sbin/httpd/src/main/http_core.c | 10 | ||||
-rw-r--r-- | usr.sbin/httpd/src/main/http_protocol.c | 26 | ||||
-rw-r--r-- | usr.sbin/httpd/src/modules/experimental/mod_mmap_static.c | 2 |
4 files changed, 20 insertions, 24 deletions
diff --git a/usr.sbin/httpd/src/include/http_protocol.h b/usr.sbin/httpd/src/include/http_protocol.h index 39e416e7e2a..d96be72703b 100644 --- a/usr.sbin/httpd/src/include/http_protocol.h +++ b/usr.sbin/httpd/src/include/http_protocol.h @@ -1,4 +1,4 @@ -/* $OpenBSD: http_protocol.h,v 1.12 2009/06/02 23:36:40 pyr Exp $ */ +/* $OpenBSD: http_protocol.h,v 1.13 2010/02/23 08:15:27 pyr Exp $ */ /* ==================================================================== * The Apache Software License, Version 1.1 @@ -140,8 +140,8 @@ API_EXPORT(long) ap_send_fd_length(FILE *f, request_rec *r, long length); API_EXPORT(long) ap_send_fb(BUFF *f, request_rec *r); API_EXPORT(long) ap_send_fb_length(BUFF *f, request_rec *r, long length); -API_EXPORT(size_t) ap_send_mmap(void *mm, request_rec *r, size_t offset, - size_t length); +API_EXPORT(off_t) ap_send_mmap(void *mm, request_rec *r, off_t offset, + off_t length); /* Hmmm... could macrofy these for now, and maybe forever, though the * definitions of the macros would get a whole lot hairier. diff --git a/usr.sbin/httpd/src/main/http_core.c b/usr.sbin/httpd/src/main/http_core.c index 229c213215a..035bc2fc160 100644 --- a/usr.sbin/httpd/src/main/http_core.c +++ b/usr.sbin/httpd/src/main/http_core.c @@ -1,4 +1,4 @@ -/* $OpenBSD: http_core.c,v 1.25 2008/05/21 11:28:48 mbalmer Exp $ */ +/* $OpenBSD: http_core.c,v 1.26 2010/02/23 08:15:27 pyr Exp $ */ /* ==================================================================== * The Apache Software License, Version 1.1 @@ -3459,15 +3459,15 @@ static int default_handler(request_rec *r) ap_send_fd(f, r); } else { - long offset, length; + off_t offset, length; while (ap_each_byterange(r, &offset, &length)) { /* * Non zero returns are more portable than checking * for a return of -1. */ - if (fseek(f, offset, SEEK_SET)) { + if (fseeko(f, offset, SEEK_SET)) { ap_log_error(APLOG_MARK, APLOG_ERR, r->server, - "Failed to fseek for byterange (%ld, %ld): %s", + "Failed to fseeko for byterange (%qd, %qd): %s", offset, length, r->filename); } else { @@ -3504,7 +3504,7 @@ static int default_handler(request_rec *r) ap_send_mmap(mm, r, 0, r->finfo.st_size); } else { - long offset, length; + off_t offset, length; while (ap_each_byterange(r, &offset, &length)) { ap_send_mmap(mm, r, offset, length); } diff --git a/usr.sbin/httpd/src/main/http_protocol.c b/usr.sbin/httpd/src/main/http_protocol.c index c4bc80386e9..429613078dd 100644 --- a/usr.sbin/httpd/src/main/http_protocol.c +++ b/usr.sbin/httpd/src/main/http_protocol.c @@ -1,4 +1,4 @@ -/* $OpenBSD: http_protocol.c,v 1.35 2009/06/02 23:36:40 pyr Exp $ */ +/* $OpenBSD: http_protocol.c,v 1.36 2010/02/23 08:15:27 pyr Exp $ */ /* ==================================================================== * The Apache Software License, Version 1.1 @@ -156,11 +156,9 @@ static enum byterange_token return BYTERANGE_EMPTY; } - if (ap_isdigit(*r->range)) { - *start = strtonum(r->range, QUAD_MIN, QUAD_MAX, &estr); - if (estr) - return BYTERANGE_BADSYNTAX; - } else + if (ap_isdigit(*r->range)) + *start = strtoll(r->range, (char **)&r->range, 10); + else *start = -1; while (ap_isspace(*r->range)) @@ -173,11 +171,9 @@ static enum byterange_token while (ap_isspace(*r->range)) ++r->range; - if (ap_isdigit(*r->range)) { - *end = strtonum(r->range, QUAD_MIN, QUAD_MAX, &estr); - if (estr) - return BYTERANGE_BADSYNTAX; - } else + if (ap_isdigit(*r->range)) + *end = strtoll(r->range, (char **)&r->range, 10); + else *end = -1; while (ap_isspace(*r->range)) @@ -2430,11 +2426,11 @@ API_EXPORT(long) ap_send_fb_length(BUFF *fb, request_rec *r, long length) #endif /* send data from an in-memory buffer */ -API_EXPORT(size_t) ap_send_mmap(void *mm, request_rec *r, size_t offset, - size_t length) +API_EXPORT(off_t) ap_send_mmap(void *mm, request_rec *r, off_t offset, + off_t length) { - size_t total_bytes_sent = 0; - int n, w; + off_t total_bytes_sent = 0; + off_t n, w; if (length == 0) return 0; diff --git a/usr.sbin/httpd/src/modules/experimental/mod_mmap_static.c b/usr.sbin/httpd/src/modules/experimental/mod_mmap_static.c index 46f261aa820..439a915e611 100644 --- a/usr.sbin/httpd/src/modules/experimental/mod_mmap_static.c +++ b/usr.sbin/httpd/src/modules/experimental/mod_mmap_static.c @@ -356,7 +356,7 @@ static int mmap_static_handler(request_rec *r) ap_send_mmap (match->mm, r, 0, match->finfo.st_size); } else { - long offset, length; + off_t offset, length; while (ap_each_byterange(r, &offset, &length)) { ap_send_mmap(match->mm, r, offset, length); } |