Skip to content

Commit

Permalink
Remove dependency from unicode PR
Browse files Browse the repository at this point in the history
  • Loading branch information
Smjert committed Nov 1, 2023
1 parent 2126355 commit a40a5a0
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions osquery/tables/utility/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ boost::optional<LnkData> parseLnkData(const fs::path& link) {
}

constexpr auto max_chars = INFOTIPSIZE > MAX_PATH ? INFOTIPSIZE : MAX_PATH;
WCHAR buffer[max_chars]{};
WCHAR buffer[max_chars + 1]{};

WIN32_FIND_DATA target_data{};
hres = shell_link->GetPath(&buffer[0], max_chars, &target_data, 0);
Expand All @@ -130,9 +130,12 @@ boost::optional<LnkData> parseLnkData(const fs::path& link) {

LnkData link_data;

link_data.target_path = wstringToString(buffer, max_chars);
link_data.target_path = wstringToString(buffer);

auto type_name_length =
wcsnlen(file_info.szTypeName, ARRAYSIZE(file_info.szTypeName));
link_data.target_type =
wstringToString(file_info.szTypeName, ARRAYSIZE(file_info.szTypeName));
wstringToString(std::wstring(file_info.szTypeName, type_name_length));

fs::path target_path = link_data.target_path;
link_data.target_location = target_path.parent_path().filename().string();
Expand All @@ -144,7 +147,7 @@ boost::optional<LnkData> parseLnkData(const fs::path& link) {
return boost::none;
}

link_data.start_in = wstringToString(buffer, max_chars);
link_data.start_in = wstringToString(buffer);

std::memset(buffer, 0, sizeof(buffer));
hres = shell_link->GetDescription(buffer, max_chars);
Expand All @@ -153,7 +156,7 @@ boost::optional<LnkData> parseLnkData(const fs::path& link) {
return boost::none;
}

link_data.comment = wstringToString(buffer, max_chars);
link_data.comment = wstringToString(buffer);

int show_cmd = 0;
hres = shell_link->GetShowCmd(&show_cmd);
Expand Down

0 comments on commit a40a5a0

Please sign in to comment.