@@ -70,22 +70,20 @@ void MultipartPartTmpFile::Open() {
70
70
71
71
localtime_r (&tt, &timeinfo);
72
72
73
- char tstr[300 ] {} ;
74
- strftime (tstr, 299 , " /%Y%m%d-%H%M%S" , &timeinfo);
73
+ char tstr[17 ] ;
74
+ strftime (tstr, std::size (tstr) , " /%Y%m%d-%H%M%S" , &timeinfo);
75
75
76
76
std::string path = m_transaction->m_rules ->m_uploadDirectory .m_value ;
77
77
path = path + tstr + " -" + *m_transaction->m_id .get ();
78
78
path += " -file-XXXXXX" ;
79
79
80
- char * tmp = strdup (path.c_str ());
81
80
#ifndef WIN32
82
- m_tmp_file_fd = mkstemp (tmp );
81
+ m_tmp_file_fd = mkstemp (path. data () );
83
82
#else
84
- _mktemp_s (tmp , path.length ()+1 );
85
- m_tmp_file_fd = _open (tmp , _O_CREAT | _O_EXCL | _O_RDWR);
83
+ _mktemp_s (path. data () , path.length ()+1 );
84
+ m_tmp_file_fd = _open (path. c_str () , _O_CREAT | _O_EXCL | _O_RDWR);
86
85
#endif
87
- m_tmp_file_name.assign (tmp);
88
- free (tmp);
86
+ m_tmp_file_name = path;
89
87
ms_dbg_a (m_transaction, 4 , " MultipartPartTmpFile: Create filename= " + m_tmp_file_name);
90
88
91
89
int mode = m_transaction->m_rules ->m_uploadFileMode .m_value ;
@@ -857,7 +855,7 @@ int Multipart::process_part_header(std::string *error, int offset) {
857
855
}
858
856
859
857
new_value = std::string (data);
860
- utils::string::chomp (& new_value);
858
+ utils::string::chomp (new_value);
861
859
862
860
/* update the header value in the table */
863
861
header_value = m_mpp->m_headers .at (
@@ -926,7 +924,7 @@ int Multipart::process_part_header(std::string *error, int offset) {
926
924
i++;
927
925
}
928
926
header_value = std::string (data);
929
- utils::string::chomp (& header_value);
927
+ utils::string::chomp (header_value);
930
928
931
929
/* error if the name already exists */
932
930
if (m_mpp->m_headers .count (header_name) > 0 ) {
@@ -1271,22 +1269,10 @@ int Multipart::multipart_complete(std::string *error) {
1271
1269
1272
1270
1273
1271
int Multipart::count_boundary_params (const std::string& str_header_value) {
1274
- std::string lower = utils::string::tolower (str_header_value);
1275
- const char *header_value = lower.c_str ();
1276
- char *duplicate = NULL ;
1277
- char *s = NULL ;
1278
1272
int count = 0 ;
1279
1273
1280
- if (header_value == NULL ) {
1281
- return -1 ;
1282
- }
1283
-
1284
- duplicate = strdup (header_value);
1285
- if (duplicate == NULL ) {
1286
- return -1 ;
1287
- }
1288
-
1289
- s = duplicate;
1274
+ const auto lower = utils::string::tolower (str_header_value);
1275
+ const char *s = lower.c_str ();
1290
1276
while ((s = strstr (s, " boundary" )) != NULL ) {
1291
1277
s += 8 ;
1292
1278
@@ -1295,7 +1281,6 @@ int Multipart::count_boundary_params(const std::string& str_header_value) {
1295
1281
}
1296
1282
}
1297
1283
1298
- free (duplicate);
1299
1284
return count;
1300
1285
}
1301
1286
0 commit comments