summaryrefslogtreecommitdiffstats
path: root/mod_intercept_form_submit.c
diff options
context:
space:
mode:
authorJan Pazdziora <jpazdziora@redhat.com>2022-01-29 20:29:00 +0100
committerJan Pazdziora <jpazdziora@redhat.com>2022-01-30 12:56:45 +0100
commit5f31c583914282e48b9d1ca55b18f4cecdcbfbed (patch)
tree636668443a543866a3aa01ee9aeb78d1ce17bd7d /mod_intercept_form_submit.c
parenta00364dd8c23b0644fab6924aa48fedf32e2ee12 (diff)
downloadmod_intercept_form_submit-5f31c583914282e48b9d1ca55b18f4cecdcbfbed.tar.gz
mod_intercept_form_submit-5f31c583914282e48b9d1ca55b18f4cecdcbfbed.tar.xz
mod_intercept_form_submit-5f31c583914282e48b9d1ca55b18f4cecdcbfbed.zip
Do fragment allocation using pool.
Diffstat (limited to 'mod_intercept_form_submit.c')
-rw-r--r--mod_intercept_form_submit.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/mod_intercept_form_submit.c b/mod_intercept_form_submit.c
index 1b90db3..849523f 100644
--- a/mod_intercept_form_submit.c
+++ b/mod_intercept_form_submit.c
@@ -369,15 +369,16 @@ static apr_status_t intercept_form_submit_filter_prefetch(request_rec * r, ifs_c
while ((nbytes > 0) && (e = memchr(p, '&', nbytes))) {
if (fragment) {
int new_length = fragment_length + (e - p);
- fragment = realloc(fragment, new_length);
- memcpy(fragment + fragment_length, p, e - p);
+ char * new_fragment = apr_palloc(r->pool, new_length);
+ memcpy(new_fragment, fragment, fragment_length);
+ memcpy(new_fragment + fragment_length, p, e - p);
if (intercept_form_submit_process_buffer(f, config, &login_value, &password_value,
- fragment, new_length, fragment_start_bucket, fragment_start_bucket_offset, &out_status)) {
+ new_fragment, new_length, fragment_start_bucket, fragment_start_bucket_offset, &out_status)) {
fetch_more = 0;
break;
}
- free(fragment);
fragment = NULL;
+ fragment_length = 0;
} else {
if (intercept_form_submit_process_buffer(f, config, &login_value, &password_value,
p, e - p, b, (p - buffer), &out_status)) {
@@ -393,8 +394,10 @@ static apr_status_t intercept_form_submit_filter_prefetch(request_rec * r, ifs_c
if (nbytes > 0) {
if (fragment) {
int new_length = fragment_length + nbytes;
- fragment = realloc(fragment, new_length);
- memcpy(fragment + fragment_length, p, nbytes);
+ char * new_fragment = apr_palloc(r->pool, new_length);
+ memcpy(new_fragment, fragment, fragment_length);
+ memcpy(new_fragment + fragment_length, p, nbytes);
+ fragment = new_fragment;
fragment_length = new_length;
} else if (APR_BUCKET_NEXT(b) && APR_BUCKET_IS_EOS(APR_BUCKET_NEXT(b))) {
/* shortcut if this is the last bucket, slurp the rest */
@@ -402,7 +405,7 @@ static apr_status_t intercept_form_submit_filter_prefetch(request_rec * r, ifs_c
p, nbytes, b, (p - buffer), &out_status);
fetch_more = 0;
} else {
- fragment = malloc(nbytes);
+ fragment = apr_palloc(r->pool, nbytes);
memcpy(fragment, p, nbytes);
fragment_length = nbytes;
fragment_start_bucket = b;
@@ -411,8 +414,6 @@ static apr_status_t intercept_form_submit_filter_prefetch(request_rec * r, ifs_c
}
}
}
- if (fragment)
- free(fragment);
return out_status == AUTH_GRANTED ? OK : DECLINED;
}