You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by jo...@apache.org on 2004/05/25 16:36:18 UTC
cvs commit: httpd-2.0/modules/http http_protocol.c
jorton 2004/05/25 07:36:18
Modified: modules/http http_protocol.c
Log:
* modules/http/http_protocol.c (ap_setup_client_block,
ap_http_filter): Use new apr_strtoff() to support request bodies as
large as apr_off_t allows (rather than as large as 'long' allows), and
simplify error handling.
PR: 27866
Revision Changes Path
1.480 +10 -23 httpd-2.0/modules/http/http_protocol.c
Index: http_protocol.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/http/http_protocol.c,v
retrieving revision 1.479
retrieving revision 1.480
diff -d -u -r1.479 -r1.480
--- http_protocol.c 9 Feb 2004 20:29:20 -0000 1.479
+++ http_protocol.c 25 May 2004 14:36:18 -0000 1.480
@@ -764,25 +764,19 @@
}
}
else if (lenp) {
- int conversion_error = 0;
char *endstr;
ctx->state = BODY_LENGTH;
errno = 0;
- ctx->remaining = strtol(lenp, &endstr, 10); /* we depend on ANSI */
-
- /* This protects us from over/underflow (the errno check),
- * non-digit chars in the string (excluding leading space)
- * (the endstr checks) and a negative number. Depending
- * on the strtol implementation, the errno check may also
- * trigger on an all whitespace string */
- if (errno || (endstr && *endstr) || (ctx->remaining < 0)) {
- conversion_error = 1;
- }
-
- if (conversion_error) {
+
+ /* Protects against over/underflow, non-digit chars in the
+ * string (excluding leading space) (the endstr checks)
+ * and a negative number. */
+ if (apr_strtoff(&ctx->remaining, lenp, &endstr, 10)
+ || *endstr || ctx->remaining < 0) {
apr_bucket_brigade *bb;
+ ctx->remaining = 0;
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, f->r,
"Invalid Content-Length");
@@ -1766,18 +1760,11 @@
r->read_chunked = 1;
}
else if (lenp) {
- int conversion_error = 0;
char *endstr;
- errno = 0;
- r->remaining = strtol(lenp, &endstr, 10); /* depend on ANSI */
-
- /* See comments in ap_http_filter() */
- if (errno || (endstr && *endstr) || (r->remaining < 0)) {
- conversion_error = 1;
- }
-
- if (conversion_error) {
+ if (apr_strtoff(&r->remaining, lenp, &endstr, 10)
+ || *endstr || r->remaining < 0) {
+ r->remaining = 0;
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
"Invalid Content-Length");
return HTTP_BAD_REQUEST;