Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
5f22dfd
Add options to store files directly to the file system and to omit du…
ctomahogh Feb 8, 2022
916610a
Delete accidentially added newline in http_resource.hpp
ctomahogh Feb 9, 2022
d9adfcb
Removed unused function, fixed some code style and typos in comments
ctomahogh Feb 10, 2022
220fdd8
Removed asprintf in favor or string concatenation
ctomahogh Feb 10, 2022
52cb06f
Made http_utils::generate_random_upload_filename plattform independant
ctomahogh Feb 10, 2022
71d1f20
Input and output of http_utils::generate_random_upload_filename are c…
ctomahogh Feb 10, 2022
1f37cfa
Added options and functions for file upload to README.md
ctomahogh Feb 10, 2022
fac086a
Use correct include and functions in generate_random_upload_filename …
ctomahogh Feb 10, 2022
5843f5f
Add missing includes for windows, fixed wrong argument for _mktemp_s
ctomahogh Feb 10, 2022
bc5a4fe
Removed accidentially pushed debug code
ctomahogh Feb 11, 2022
8d7ea8e
Use a static const char* for the random file system template
ctomahogh Feb 11, 2022
329c066
Make output of get_or_create_file_info const and introduce new setters
ctomahogh Feb 11, 2022
07e9f4d
Use const variables for the webserver options
ctomahogh Feb 11, 2022
29ba743
Added an example for file upload
ctomahogh Feb 11, 2022
2606d61
Use a prefixed operator in for loop
ctomahogh Feb 11, 2022
8ab2972
Added safety check for use of strlen and some missing free()s
ctomahogh Feb 14, 2022
3880d8d
Changed file map to be a map of keys with a nested map of files
ctomahogh Feb 14, 2022
2e99b1d
Adjusted file_upload example to use new files map
ctomahogh Feb 14, 2022
fd7bab9
Updated description of files map in README.md
ctomahogh Feb 14, 2022
ccc67e8
Removed strlen from generate_random_upload_filename
ctomahogh Feb 14, 2022
799c201
Use a pointer to std::ofstream in modded_request
ctomahogh Feb 15, 2022
f329061
Moved struct file_info_s to class file_info
ctomahogh Feb 16, 2022
8b5c172
Setters of class file_info are private and class webserver is a frien…
ctomahogh Feb 17, 2022
cb802d1
Use const reference as parameter for set_file_system_file_name
ctomahogh Feb 17, 2022
c6151c4
Don't create zero length files if no file is uploaded
ctomahogh Feb 17, 2022
4cb49c8
Updated README.md as file_info is now a class
ctomahogh Feb 17, 2022
7f2c353
Some code styling and small refactorings after review
ctomahogh Feb 18, 2022
27fc9a8
Replaced std::exception with custom generateFilenameException
ctomahogh Feb 18, 2022
1cf683e
Some more comments and code style fixes after review
ctomahogh Feb 18, 2022
88d14aa
Some more code style changes after review
ctomahogh Feb 18, 2022
b3a39dd
Added error string to generateFilenameException
ctomahogh Feb 18, 2022
cbca260
Added comment for c functions in generate_random_upload_filename
ctomahogh Feb 18, 2022
f896540
Removed const qualifier from file_info::get_file_size()
ctomahogh Feb 20, 2022
897eab9
Merge branch 'etr:master' into upload_to_file_system
ctomahogh Feb 21, 2022
7b73c48
Added unit test for generate_random_upload_filename
ctomahogh Feb 21, 2022
4f2cecf
Removed filesystem include from unit tests again, as it would require…
ctomahogh Feb 21, 2022
c1878f5
Close open upload file after post processor is done
ctomahogh Feb 22, 2022
f189014
Added content_type and transfer_encoding to file_info
ctomahogh Feb 22, 2022
8e16406
Fixed file_upload example
ctomahogh Feb 22, 2022
4bcc846
Made filename_template and path_separator part of class http_utils
ctomahogh Feb 22, 2022
f4fb34f
Added integration test for file upload
ctomahogh Feb 25, 2022
0e90742
Fixed integration test for file upload
ctomahogh Feb 25, 2022
ee91ea9
Merge branch 'etr:master' into upload_to_file_system
ctomahogh Feb 26, 2022
ac91c63
Removed empty AUTO_TEST from file_upload integration test
ctomahogh Feb 26, 2022
f13d1fe
Use internal values for http_ressource class in integration tests
ctomahogh Mar 2, 2022
91b90e5
Added further integration tests for file upload
ctomahogh Mar 3, 2022
4de82c9
Added test_content_2 to configure script
ctomahogh Mar 3, 2022
acebdfa
Fixed memory leak in post_iterator
ctomahogh Mar 3, 2022
6fff5f0
Some code style fixed on file upload integration test
ctomahogh Mar 3, 2022
dbba47c
Use map definition instead of auto in integration test
ctomahogh Mar 3, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Removed strlen from generate_random_upload_filename
As Codacy static code analysis warns about the safety issue of strlen
if a given string is not terminated, this is removed.
The solution uses the size of the original string, which is just duplicated
to a char* as the used function _mktemp_s requires a char* which will
be changed by the function and the changed result is needed afterwards.
  • Loading branch information
ctomahogh committed Feb 14, 2022
commit ccc67e87f86fa26e04db41ed7403eaf3541f15ea
6 changes: 1 addition & 5 deletions src/http_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,8 @@ const std::string http_utils::generate_random_upload_filename(const std::string&
char *template_filename = strdup(filename.c_str());
int fd = 0;

if (template_filename == NULL) {
throw std::exception();
}

#if defined(_WIN32)
if (0 != _mktemp_s(template_filename, strlen(template_filename) + 1)) {
if (0 != _mktemp_s(template_filename, filename.size() + 1)) {
free(template_filename);
throw std::exception();
}
Expand Down