Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

file: Add Shortcut metadata parsing on Windows #8143

Merged
merged 6 commits into from
Nov 28, 2023
Merged
Changes from 1 commit
Commits
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
review: Resolve leaks
  • Loading branch information
Smjert committed Nov 22, 2023
commit ecd100adf7ff276461a425271ad5533e00fe4fb6
6 changes: 6 additions & 0 deletions osquery/tables/utility/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <osquery/filesystem/fileops.h>
#include <osquery/filesystem/filesystem.h>
#include <osquery/logger/logger.h>
#include <osquery/utils/scope_guard.h>
#include <osquery/worker/ipc/platform_table_container_ipc.h>
#include <osquery/worker/logging/glog/glog_logger.h>

Expand Down Expand Up @@ -74,6 +75,9 @@ boost::optional<LnkData> parseLnkData(const fs::path& link) {
return boost::none;
}

auto shell_link_release =
scope_guard::create([shell_link]() { shell_link->Release(); });

IPersistFile* file;
hres = shell_link->QueryInterface(IID_IPersistFile,
reinterpret_cast<LPVOID*>(&file));
Expand All @@ -84,6 +88,8 @@ boost::optional<LnkData> parseLnkData(const fs::path& link) {
return boost::none;
}

auto file_link_release = scope_guard::create([file]() { file->Release(); });

hres = file->Load(link.c_str(), STGM_READ);

if (FAILED(hres)) {
Expand Down