Skip to content

Commit

Permalink
Merge pull request #53 from unknownv2/coreload-v2
Browse files Browse the repository at this point in the history
Use wcsnlen instead of wclen to validate user DLL paths and names
  • Loading branch information
unknownv2 committed Jan 26, 2019
2 parents c00c08f + 86d6692 commit 5e6abc8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/coreload/common/pal.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ namespace coreload
pal::string_t to_lower(const pal::string_t& in);

inline size_t strlen(const char_t* str) { return ::wcslen(str); }
inline size_t strnlen(const char_t* str, size_t max_size) { return ::wcsnlen(str, max_size); }
inline errno_t file_open(const pal::string_t& path, const char_t* mode, FILE* stream) { return ::_wfopen_s(&stream, path.c_str(), mode); }
inline void file_vprintf(FILE* f, const char_t* format, va_list vl) { ::vfwprintf(f, format, vl); ::fputwc(_X('\n'), f); }
inline void err_fputs(const char_t* message) { ::fputws(message, stderr); ::fputwc(_X('\n'), stderr); }
Expand Down
2 changes: 1 addition & 1 deletion src/coreload/dll/coreload.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ int ValidateArgument(
{
if (argument != nullptr)
{
const size_t string_length = pal::strlen(argument);
const size_t string_length = pal::strnlen(argument, max_size);
if (string_length == 0 || string_length >= max_size)
{
return StatusCode::InvalidArgFailure;
Expand Down

0 comments on commit 5e6abc8

Please sign in to comment.