mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-15 23:55:03 +03:00
Removed unnecessary copies
This commit is contained in:
parent
f8dd09f7c9
commit
1534ee2448
@ -70,22 +70,20 @@ void MultipartPartTmpFile::Open() {
|
|||||||
|
|
||||||
localtime_r(&tt, &timeinfo);
|
localtime_r(&tt, &timeinfo);
|
||||||
|
|
||||||
char tstr[300] {};
|
char tstr[17];
|
||||||
strftime(tstr, 299, "/%Y%m%d-%H%M%S", &timeinfo);
|
strftime(tstr, std::size(tstr), "/%Y%m%d-%H%M%S", &timeinfo);
|
||||||
|
|
||||||
std::string path = m_transaction->m_rules->m_uploadDirectory.m_value;
|
std::string path = m_transaction->m_rules->m_uploadDirectory.m_value;
|
||||||
path = path + tstr + "-" + *m_transaction->m_id.get();
|
path = path + tstr + "-" + *m_transaction->m_id.get();
|
||||||
path += "-file-XXXXXX";
|
path += "-file-XXXXXX";
|
||||||
|
|
||||||
char* tmp = strdup(path.c_str());
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
m_tmp_file_fd = mkstemp(tmp);
|
m_tmp_file_fd = mkstemp(path.data());
|
||||||
#else
|
#else
|
||||||
_mktemp_s(tmp, path.length()+1);
|
_mktemp_s(path.data(), path.length()+1);
|
||||||
m_tmp_file_fd = _open(tmp, _O_CREAT | _O_EXCL | _O_RDWR);
|
m_tmp_file_fd = _open(path.c_str(), _O_CREAT | _O_EXCL | _O_RDWR);
|
||||||
#endif
|
#endif
|
||||||
m_tmp_file_name.assign(tmp);
|
m_tmp_file_name = path;
|
||||||
free(tmp);
|
|
||||||
ms_dbg_a(m_transaction, 4, "MultipartPartTmpFile: Create filename= " + m_tmp_file_name);
|
ms_dbg_a(m_transaction, 4, "MultipartPartTmpFile: Create filename= " + m_tmp_file_name);
|
||||||
|
|
||||||
int mode = m_transaction->m_rules->m_uploadFileMode.m_value;
|
int mode = m_transaction->m_rules->m_uploadFileMode.m_value;
|
||||||
@ -1271,22 +1269,10 @@ int Multipart::multipart_complete(std::string *error) {
|
|||||||
|
|
||||||
|
|
||||||
int Multipart::count_boundary_params(const std::string& str_header_value) {
|
int Multipart::count_boundary_params(const std::string& str_header_value) {
|
||||||
std::string lower = utils::string::tolower(str_header_value);
|
|
||||||
const char *header_value = lower.c_str();
|
|
||||||
char *duplicate = NULL;
|
|
||||||
char *s = NULL;
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
if (header_value == NULL) {
|
const auto lower = utils::string::tolower(str_header_value);
|
||||||
return -1;
|
const char *s = lower.c_str();
|
||||||
}
|
|
||||||
|
|
||||||
duplicate = strdup(header_value);
|
|
||||||
if (duplicate == NULL) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
s = duplicate;
|
|
||||||
while ((s = strstr(s, "boundary")) != NULL) {
|
while ((s = strstr(s, "boundary")) != NULL) {
|
||||||
s += 8;
|
s += 8;
|
||||||
|
|
||||||
@ -1295,7 +1281,6 @@ int Multipart::count_boundary_params(const std::string& str_header_value) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free(duplicate);
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user