mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 05:45:59 +03:00
Don't unnecessarily rename request body parts in cleanup
When tmp_dir and upload_dir are identical, there's no reason to rename multipart and request body parts, as this is a non-op. Let's save the cycles and syscall.
This commit is contained in:
parent
8559dd3b8b
commit
709042a472
@ -1327,6 +1327,11 @@ apr_status_t multipart_cleanup(modsec_rec *msr) {
|
||||
} else {
|
||||
/* Move file to the upload dir. */
|
||||
if (parts[i]->tmp_file_name != NULL) {
|
||||
if (strcmp(msr->txcfg->upload_dir, msr->txcfg->tmp_dir) == 0) {
|
||||
msr_log(msr, 4, "Not moving part to identical location");
|
||||
continue;
|
||||
}
|
||||
|
||||
const char *new_filename = NULL;
|
||||
const char *new_basename = NULL;
|
||||
|
||||
|
@ -884,6 +884,11 @@ apr_status_t modsecurity_request_body_clear(modsec_rec *msr, char **error_msg) {
|
||||
|
||||
if (msr->msc_reqbody_filename != NULL) {
|
||||
if (keep_body) {
|
||||
if (strcmp(msr->txcfg->upload_dir, msr->txcfg->tmp_dir) == 0) {
|
||||
msr_log(msr, 4, "Not moving file to identical location.");
|
||||
goto nullify;
|
||||
}
|
||||
|
||||
/* Move request body (which is a file) to the storage area. */
|
||||
const char *put_filename = NULL;
|
||||
const char *put_basename = NULL;
|
||||
@ -933,6 +938,8 @@ apr_status_t modsecurity_request_body_clear(modsec_rec *msr, char **error_msg) {
|
||||
msr->msc_reqbody_filename);
|
||||
}
|
||||
|
||||
nullify:
|
||||
|
||||
msr->msc_reqbody_filename = NULL;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user