joes 2004/06/11 09:46:37
Modified: glue/perl/xsbuilder/Apache/Request Apache__Request.h
Log:
Eliminate off_t/size_t warning in apreq_x_upload_slurp, following Geoffrey
Young's patch.
Revision Changes Path
1.27 +12 -7
httpd-apreq-2/glue/perl/xsbuilder/Apache/Request/Apache__Request.h
Index: Apache__Request.h
===================================================================
RCS file:
/home/cvs/httpd-apreq-2/glue/perl/xsbuilder/Apache/Request/Apache__Request.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- Apache__Request.h 8 Jun 2004 04:18:22 -0000 1.26
+++ Apache__Request.h 11 Jun 2004 16:46:37 -0000 1.27
@@ -177,7 +177,8 @@
MAGIC *mg;
void *env;
char *data;
- apr_off_t len;
+ apr_off_t len_off;
+ apr_size_t len_size;
apr_bucket_brigade *bb;
apr_status_t s;
@@ -190,17 +191,21 @@
env = mg->mg_ptr;
bb = apreq_xs_rv2param(ST(0))->bb;
- s = apr_brigade_length(bb, 0, &len);
+ s = apr_brigade_length(bb, 0, &len_off);
if (s != APR_SUCCESS)
XSRETURN_IV(s);
+ len_size = len_off; /* max_body setting will be low enough to prevent
+ * overflow, but even if it wasn't the code below
will
+ * at worst truncate the slurp data (not segfault).
+ */
+
SvUPGRADE(ST(1), SVt_PV);
- data = SvGROW(ST(1), len + 1);
- data[len] = 0;
- SvCUR_set(ST(1), len);
+ data = SvGROW(ST(1), len_size + 1);
+ data[len_size] = 0;
+ SvCUR_set(ST(1), len_size);
SvPOK_only(ST(1));
-
- s = apr_brigade_flatten(bb, data, &len);
+ s = apr_brigade_flatten(bb, data, &len_size);
XSRETURN_IV(s);
}