joes 2004/07/05 10:39:50
Modified: . CHANGES
env mod_apreq.c
glue/perl/t/response/TestApReq request.pm
src apreq_cookie.c apreq_env.c apreq_version.h
Log:
Restrict all apr_status_t codes to APR_SUCCESS, APR_INCOMPLETE,
APR_EGENERAL, APR_EINIT, APR_ENOTIMPL, since any others will
generate confusing error messages from apr_strerror.
Revision Changes Path
1.51 +5 -0 httpd-apreq-2/CHANGES
Index: CHANGES
===================================================================
RCS file: /home/cvs/httpd-apreq-2/CHANGES,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -r1.50 -r1.51
--- CHANGES 4 Jul 2004 17:44:34 -0000 1.50
+++ CHANGES 5 Jul 2004 17:39:50 -0000 1.51
@@ -3,6 +3,11 @@
@section v2_04_dev Changes with libapreq2-2.04-dev
+- C API [joes]
+ Restrict all apr_status_t codes to APR_SUCCESS, APR_INCOMPLETE,
+ APR_EGENERAL, APR_EINIT, APR_ENOTIMPL, since any others will
+ generate confusing error messages from apr_strerror.
+
- Perl API [joes]
Added $upload->io with a TIEHANDLE API layered over APR::Brigade.
$upload->fh
remains implemented as an APR::PerlIO object, which is seekable but less
efficient
1.56 +8 -8 httpd-apreq-2/env/mod_apreq.c
Index: mod_apreq.c
===================================================================
RCS file: /home/cvs/httpd-apreq-2/env/mod_apreq.c,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -r1.55 -r1.56
--- mod_apreq.c 23 Jun 2004 15:47:55 -0000 1.55
+++ mod_apreq.c 5 Jul 2004 17:39:50 -0000 1.56
@@ -72,7 +72,7 @@
request_rec *r; /* request that originally created this
filter */
apr_bucket_brigade *bb; /* input brigade that's passed to the parser
*/
apr_bucket_brigade *spool; /* copied prefetch data for downstream
filters */
- apr_status_t status;/* APR_SUCCESS, APR_COMPLETE, or parse error
*/
+ apr_status_t status;/* APR_SUCCESS, APR_INCOMPLETE, or parse
error */
unsigned saw_eos; /* Has EOS bucket appeared in filter?
*/
apr_off_t bytes_read; /* Total bytes read into this filter.
*/
};
@@ -131,7 +131,7 @@
* <TR class="odd"><TD>APREQ_MaxBody</TD><TD>directory</TD><TD>-1
(Unlimited)</TD><TD>
* Maximum number of bytes mod_apreq will send off to libapreq for parsing.
* mod_apreq will log this event and remove itself from the filter chain.
- * The APR_ENOSPC (XXX) error will be reported to libapreq2 users via the
return
+ * The APR_EGENERAL error will be reported to libapreq2 users via the return
* value of apreq_env_read().
* </TD></TR>
* <TR><TD>APREQ_MaxBrigade</TD><TD>directory</TD><TD>
#APREQ_MAX_BRIGADE_LEN </TD><TD>
@@ -157,7 +157,7 @@
#define APREQ_MODULE_NAME "APACHE2"
-#define APREQ_MODULE_MAGIC_NUMBER 20040623
+#define APREQ_MODULE_MAGIC_NUMBER 20040705
static void apache2_log(const char *file, int line, int level,
apr_status_t status, void *env, const char *fmt,
@@ -310,9 +310,9 @@
apr_int64_t content_length = apr_strtoi64(cl,&dummy,0);
if (dummy == NULL || *dummy != 0) {
- apreq_log(APREQ_ERROR APR_BADARG, r,
- "invalid Content-Length header (%s)", cl);
- ctx->status = APR_BADARG;
+ apreq_log(APREQ_ERROR APR_EGENERAL, r,
+ "Invalid Content-Length header (%s)", cl);
+ ctx->status = APR_EGENERAL;
}
else if (content_length > (apr_int64_t)cfg->max_body) {
apreq_log(APREQ_ERROR APR_EINIT, r,
@@ -554,7 +554,7 @@
ctx->bytes_read += len;
if (cfg->max_body >= 0 && ctx->bytes_read > cfg->max_body) {
- ctx->status = APR_ENOSPC;
+ ctx->status = APR_EGENERAL;
apreq_log(APREQ_ERROR ctx->status, r, "Bytes read ("
APR_OFF_T_FMT
") exceeds configured max_body limit ("
APR_OFF_T_FMT ")",
ctx->bytes_read, cfg->max_body);
@@ -621,7 +621,7 @@
ctx->bytes_read += total_read;
if (cfg->max_body >= 0 && ctx->bytes_read > cfg->max_body) {
- ctx->status = APR_ENOSPC;
+ ctx->status = APR_EGENERAL;
apreq_log(APREQ_ERROR ctx->status, r, "Bytes read (%"
APR_OFF_T_FMT
") exceeds configured max_body limit (%" APR_OFF_T_FMT
")",
ctx->bytes_read, cfg->max_body);
1.22 +2 -1 httpd-apreq-2/glue/perl/t/response/TestApReq/request.pm
Index: request.pm
===================================================================
RCS file: /home/cvs/httpd-apreq-2/glue/perl/t/response/TestApReq/request.pm,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- request.pm 5 Jul 2004 14:28:18 -0000 1.21
+++ request.pm 5 Jul 2004 17:39:50 -0000 1.22
@@ -16,7 +16,8 @@
sub handler {
my $r = shift;
my $temp_dir = $r->server->server_root_relative('logs');
- my $req = Apache::Request->new($r, TEMP_DIR => $temp_dir);
+ my $req = Apache::Request->new($r, POST_MAX => 1_000_000,
+ TEMP_DIR => $temp_dir);
$req->content_type('text/plain');
1.26 +13 -13 httpd-apreq-2/src/apreq_cookie.c
Index: apreq_cookie.c
===================================================================
RCS file: /home/cvs/httpd-apreq-2/src/apreq_cookie.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- apreq_cookie.c 1 Jul 2004 04:11:24 -0000 1.25
+++ apreq_cookie.c 5 Jul 2004 17:39:50 -0000 1.26
@@ -87,7 +87,7 @@
const char *val, apr_size_t vlen)
{
if (alen < 2)
- return APR_BADARG;
+ return APR_EGENERAL;
if ( attr[0] == '-' || attr[0] == '$' ) {
++attr;
@@ -103,7 +103,7 @@
case 'v': /* version */
while (!apr_isdigit(*val)) {
if (vlen == 0)
- return APR_BADARG;
+ return APR_EGENERAL;
++val;
--vlen;
}
@@ -193,7 +193,7 @@
if (*d++ == 0) {
/*error: no '=' sign detected */
*data = d-1;
- return APR_NOTFOUND;
+ return APR_EGENERAL;
}
}
@@ -222,7 +222,7 @@
else { /* shouldn't end on a sour note */
*vlen = d - *v;
*data = d;
- return APR_BADCH;
+ return APR_EGENERAL;
}
case '"':
@@ -237,7 +237,7 @@
*data = d;
if (in_quotes)
- return APR_BADARG;
+ return APR_EGENERAL;
return APR_SUCCESS;
}
@@ -336,14 +336,14 @@
case '$':
if (c == NULL) {
- j->status = APR_BADCH;
+ j->status = APR_EGENERAL;
apreq_log(APREQ_ERROR j->status, env,
"Saw RFC attribute, was expecting NAME=VALUE cookie
pair: %s",
hdr);
return j;
}
else if (version == NETSCAPE) {
- j->status = APR_EMISMATCH;
+ j->status = APR_EGENERAL;
apreq_log(APREQ_ERROR j->status, env,
"Saw RFC attribute in a Netscape Cookie header:
%s",
hdr);
@@ -495,10 +495,10 @@
char *s = apreq_cookie_as_string(c,apreq_env_pool(env));
if (s == NULL) {
- apreq_log(APREQ_ERROR APR_ENAMETOOLONG, env,
+ apreq_log(APREQ_ERROR APR_EGENERAL, env,
"Serialized cookie exceeds APREQ_COOKIE_MAX_LENGTH = %d",
APREQ_COOKIE_MAX_LENGTH);
- return APR_ENAMETOOLONG;
+ return APR_EGENERAL;
}
return apreq_env_set_cookie(env, s);
@@ -510,15 +510,15 @@
char *s = apreq_cookie_as_string(c,apreq_env_pool(env));
if ( s == NULL ) {
- apreq_log(APREQ_ERROR APR_ENAMETOOLONG, env,
+ apreq_log(APREQ_ERROR APR_EGENERAL, env,
"Serialized cookie exceeds APREQ_COOKIE_MAX_LENGTH = %d",
APREQ_COOKIE_MAX_LENGTH);
- return APR_ENAMETOOLONG;
+ return APR_EGENERAL;
}
else if ( c->version == NETSCAPE ) {
- apreq_log(APREQ_ERROR APR_EMISMATCH, env,
+ apreq_log(APREQ_ERROR APR_EGENERAL, env,
"Cannot bake2 a Netscape cookie: %s", s);
- return APR_EMISMATCH;
+ return APR_EGENERAL;
}
return apreq_env_set_cookie2(env, s);
1.9 +15 -5 httpd-apreq-2/src/apreq_env.c
Index: apreq_env.c
===================================================================
RCS file: /home/cvs/httpd-apreq-2/src/apreq_env.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- apreq_env.c 23 Jun 2004 02:22:28 -0000 1.8
+++ apreq_env.c 5 Jul 2004 17:39:50 -0000 1.9
@@ -146,7 +146,7 @@
#define APREQ_MODULE_NAME "CGI"
-#define APREQ_MODULE_MAGIC_NUMBER 20040619
+#define APREQ_MODULE_MAGIC_NUMBER 20040705
static apr_pool_t *cgi_pool(void *env)
{
@@ -266,8 +266,13 @@
ctx.in = apr_brigade_split(bb, e);
ctx.bytes_read += bytes;
if (ctx.max_body >= 0) {
- if (ctx.bytes_read > ctx.max_body)
- return ctx.status = APR_ENOSPC;
+ if (ctx.bytes_read > ctx.max_body) {
+ apreq_log(APREQ_ERROR APR_EGENERAL, env,
+ "Bytes read (%" APR_OFF_T_FMT
+ ") exceeds configured limit (%" APR_OFF_T_FMT ")",
+ ctx.bytes_read, ctx.max_body);
+ return ctx.status = APR_EGENERAL;
+ }
}
ctx.status = apreq_parse_request(req, bb);
apr_brigade_cleanup(bb);
@@ -281,8 +286,13 @@
return ctx.status = s;
ctx.bytes_read += len;
if (ctx.max_body >= 0) {
- if (ctx.bytes_read > ctx.max_body)
- return ctx.status = APR_ENOSPC;
+ if (ctx.bytes_read > ctx.max_body) {
+ apreq_log(APREQ_ERROR APR_EGENERAL, env,
+ "Bytes read (%" APR_OFF_T_FMT
+ ") exceeds configured limit (%" APR_OFF_T_FMT ")",
+ ctx.bytes_read, ctx.max_body);
+ return ctx.status = APR_EGENERAL;
+ }
}
ctx.status = apreq_parse_request(req, bb);
apr_brigade_cleanup(bb);
1.18 +1 -1 httpd-apreq-2/src/apreq_version.h
Index: apreq_version.h
===================================================================
RCS file: /home/cvs/httpd-apreq-2/src/apreq_version.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- apreq_version.h 1 Jul 2004 18:27:40 -0000 1.17
+++ apreq_version.h 5 Jul 2004 17:39:50 -0000 1.18
@@ -61,7 +61,7 @@
#define APREQ_MINOR_VERSION 0
/** patch level */
-#define APREQ_PATCH_VERSION 13
+#define APREQ_PATCH_VERSION 14
/**
* This symbol is defined for internal, "development" copies of libapreq.