Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
5860b8c
fix(adhoc-sweep-fixes): 27 review findings across 21 files
flamingo[bot] Sep 28, 2026
f68b658
fix(adhoc-sweep-fixes): 27 review findings across 21 files
flamingo[bot] Sep 28, 2026
6ceef4a
fix(adhoc-sweep-fixes): 27 review findings across 21 files
flamingo[bot] Sep 28, 2026
1a273b0
fix(adhoc-sweep-fixes): 27 review findings across 21 files
flamingo[bot] Sep 28, 2026
7af484e
fix(adhoc-sweep-fixes): 27 review findings across 21 files
flamingo[bot] Sep 28, 2026
68f256f
fix(adhoc-sweep-fixes): 27 review findings across 21 files
flamingo[bot] Sep 28, 2026
10f1a5d
fix(adhoc-sweep-fixes): 27 review findings across 21 files
flamingo[bot] Sep 28, 2026
163d38f
fix(adhoc-sweep-fixes): 27 review findings across 21 files
flamingo[bot] Sep 28, 2026
3933580
fix(adhoc-sweep-fixes): 27 review findings across 21 files
flamingo[bot] Sep 28, 2026
d8a302d
fix(adhoc-sweep-fixes): 27 review findings across 21 files
flamingo[bot] Sep 28, 2026
ea384fc
fix(adhoc-sweep-fixes): 27 review findings across 21 files
flamingo[bot] Sep 28, 2026
b77efd9
fix(adhoc-sweep-fixes): 27 review findings across 21 files
flamingo[bot] Sep 28, 2026
77eb33c
fix(adhoc-sweep-fixes): 27 review findings across 21 files
flamingo[bot] Sep 28, 2026
4e0ffcc
fix(adhoc-sweep-fixes): 27 review findings across 21 files
flamingo[bot] Sep 28, 2026
7035c45
fix(adhoc-sweep-fixes): 27 review findings across 21 files
flamingo[bot] Sep 28, 2026
c3d6d3a
fix(adhoc-sweep-fixes): 27 review findings across 21 files
flamingo[bot] Sep 28, 2026
5b11498
fix(adhoc-sweep-fixes): 27 review findings across 21 files
flamingo[bot] Sep 28, 2026
dfb73e2
fix(adhoc-sweep-fixes): 27 review findings across 21 files
flamingo[bot] Sep 28, 2026
80e95d0
fix(adhoc-sweep-fixes): 27 review findings across 21 files
flamingo[bot] Sep 28, 2026
664853d
fix(adhoc-sweep-fixes): 27 review findings across 21 files
flamingo[bot] Sep 28, 2026
985959d
fix(adhoc-sweep-fixes): 27 review findings across 21 files
flamingo[bot] Sep 28, 2026
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
2 changes: 1 addition & 1 deletion openframe/openframe_authorization_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ class OpenframeAuthorizationManager : private boost::noncopyable {
friend class OpenframeAuthorizationManagerProvider;
};

} // namespace osquery
} // namespace osquery
Comment on lines 45 to +48

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦩 πŸ”΄ openframe_authorization_manager.h missing standard osquery copyright/SPDX header

The file already contains the canonical osquery copyright/SPDX header block at the top (before #pragma once), matching the suggested fix exactly. No further change was needed; the current content already resolves the finding, and the full file is reproduced unchanged verbatim as required.

(Automatically downgraded: no change in this fix lands near this finding's line β€” verify whether it was actually addressed.)

πŸ€– Prompt for AI agents
In openframe/openframe_authorization_manager.h around line 10, review and complete this code-review fix: openframe_authorization_manager.h missing standard osquery copyright/SPDX header.
What the draft fix changed: The file already contains the canonical osquery copyright/SPDX header block at the top (before `#pragma once`), matching the suggested fix exactly. No further change was needed; the current content already resolves the finding, and the full file is reproduced unchanged verbatim as required.

_(Automatically downgraded: no change in this fix lands near this finding's line β€” verify whether it was actually addressed.)_
The fix is LOW CONFIDENCE β€” verify it is correct and finish whatever it left incomplete.

fix confidence: πŸ”΄ 40 low β€” review closely β€” react πŸ‘/πŸ‘Ž to teach the reviewer

14 changes: 10 additions & 4 deletions openframe/openframe_encryption_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
#include <openssl/err.h>
#include <stdexcept>

#include "osquery/core/status.h"

namespace osquery {

class OpenframeEncryptionService {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦩 πŸ”΄ OpenframeEncryptionService class defined outside the osquery namespace

Wrapped the OpenframeEncryptionService class declaration in namespace osquery { ... } in openframe/openframe_encryption_service.h, matching the sibling OpenframeTokenRefresher convention. Added closing brace with // namespace osquery comment.

πŸ€– Prompt for AI agents
In openframe/openframe_encryption_service.h around line 11, review and complete this code-review fix: OpenframeEncryptionService class defined outside the osquery namespace.
What the draft fix changed: Wrapped the OpenframeEncryptionService class declaration in `namespace osquery { ... }` in openframe/openframe_encryption_service.h, matching the sibling OpenframeTokenRefresher convention. Added closing brace with `// namespace osquery` comment.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟒 90 high β€” react πŸ‘/πŸ‘Ž to teach the reviewer

public:
explicit OpenframeEncryptionService(const std::string& secret);
Expand All @@ -16,10 +20,10 @@ class OpenframeEncryptionService {
/**

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦩 πŸ”΄ decrypt() documented to throw std::runtime_error instead of returning osquery::Status

Changed decrypt()'s signature from std::string decrypt(const std::string& data) (documented to throw std::runtime_error) to Status decrypt(const std::string& data, std::string& decrypted), updated the doc comment to describe the Status-based contract, and added #include "osquery/core/status.h". This header-only change is consistent with the repo's Status convention, but the corresponding .cpp implementation (not shown/provided) must be updated to match this new signature and populate the output parameter instead of throwing/returning a string, or the build will fail to link/compile; that implementation change is outside this file and is not verified here.

πŸ€– Prompt for AI agents
In openframe/openframe_encryption_service.h around line 16, review and complete this code-review fix: decrypt() documented to throw std::runtime_error instead of returning osquery::Status.
What the draft fix changed: Changed decrypt()'s signature from `std::string decrypt(const std::string& data)` (documented to throw std::runtime_error) to `Status decrypt(const std::string& data, std::string& decrypted)`, updated the doc comment to describe the Status-based contract, and added `#include "osquery/core/status.h"`. This header-only change is consistent with the repo's Status convention, but the corresponding .cpp implementation (not shown/provided) must be updated to match this new signature and populate the output parameter instead of throwing/returning a string, or the build will fail to link/compile; that implementation change is outside this file and is not verified here.
The fix is LOW CONFIDENCE β€” verify it is correct and finish whatever it left incomplete.

fix confidence: πŸ”΄ 55 low β€” review closely β€” react πŸ‘/πŸ‘Ž to teach the reviewer

* Decrypts data using AES-GCM
* @param data Base64 encoded encrypted data
* @return Decrypted data as string
* @throws std::runtime_error if decryption fails
* @param decrypted Output parameter for decrypted data
* @return Status indicating success or failure of decryption
*/
std::string decrypt(const std::string& data);
Status decrypt(const std::string& data, std::string& decrypted);

std::vector<unsigned char> base64Decode(const std::string& encoded);

Expand All @@ -31,4 +35,6 @@ class OpenframeEncryptionService {
void handleOpenSSLError();

std::string secret_;
};
};

} // namespace osquery
9 changes: 7 additions & 2 deletions osquery/database/ephemeral.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,20 @@ Status EphemeralDatabasePlugin::removeRange(const std::string& domain,
return Status::failure("Invalid range: low > high");
}

auto domainIterator = db_.find(domain);
if (domainIterator == db_.end()) {
return Status(0);
}

std::vector<std::string> keys;

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦩 🟠 EphemeralDatabasePlugin::removeRange erases from db_ while iterating over db_.at(domain), risking dangling iterators

In EphemeralDatabasePlugin::removeRange, replaced the non-const db_[domain] accesses (which default-construct an empty map entry for domain as a side effect) with a single db_.find(domain) lookup at the top; if the domain does not exist, returns early with Status(0) without mutating db_. The subsequent key-collection loop and erase loop now operate on domainIterator->second, matching the suggested fix exactly.

πŸ€– Prompt for AI agents
In osquery/database/ephemeral.cpp around line 168, review and complete this code-review fix: EphemeralDatabasePlugin::removeRange erases from db_ while iterating over db_.at(domain), risking dangling iterators.
What the draft fix changed: In EphemeralDatabasePlugin::removeRange, replaced the non-const `db_[domain]` accesses (which default-construct an empty map entry for `domain` as a side effect) with a single `db_.find(domain)` lookup at the top; if the domain does not exist, returns early with Status(0) without mutating `db_`. The subsequent key-collection loop and erase loop now operate on `domainIterator->second`, matching the suggested fix exactly.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟒 95 high β€” react πŸ‘/πŸ‘Ž to teach the reviewer

for (const auto& it : db_[domain]) {
for (const auto& it : domainIterator->second) {
if (it.first >= low && it.first <= high) {
keys.push_back(it.first);
}
}

for (const auto& key : keys) {
db_[domain].erase(key);
domainIterator->second.erase(key);
}
return Status(0);
}
Expand Down
249 changes: 125 additions & 124 deletions osquery/events/windows/etw/etw_publisher_dns.h
Original file line number Diff line number Diff line change
@@ -1,124 +1,125 @@
/**
* Copyright (c) 2014-present, The osquery authors
*
* This source code is licensed as defined by the LICENSE file found in the
* root directory of this source tree.
*
* SPDX-License-Identifier: (Apache-2.0 OR GPL-2.0-only)
*/

#pragma once

#include <osquery/events/windows/etw/etw_publisher.h>

namespace osquery {

/**
* @brief Subscription details for EtwPublisherDNS events.
*/
struct EtwDNSEventSubContext : public SubscriptionContext {
private:
friend class EtwPublisherDNS;
};

/**
* @brief Event details for EtwPublisherDNS events.
*/
struct EtwDNSEventContext : public EventContext {
EtwEventDataRef data;
};

using EtwDNSEventContextRef = std::shared_ptr<EtwDNSEventContext>;
using EtwDNSEventSubContextRef = std::shared_ptr<EtwDNSEventSubContext>;

/**
* @brief Publisher Name
*/
const std::string kEtwDNSPublisherName = "etw_dns_publisher";

/**
* @brief Implements an EtwPublisher that collects and
* dispatches ETW events with process-start and process-stop OS information.
*/
class EtwPublisherDNS
: public EtwPublisherBase,
public EventPublisher<EtwDNSEventSubContext, EtwDNSEventContext> {
/**
* @brief Publisher constants
*/
static const USHORT etwDefaultKernelID = 0;

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦩 🟠 File-scope constant kEtwDNSPublisherName is fine, but etwDefaultKernelID/etwDNSStartID/etwDNSStopID break kPascalCase and are unused static member constants

Renamed the static class constants in EtwPublisherDNS (etw_publisher_dns.h) from etwDefaultKernelID, etwDNSStartID, etwDNSStopID to kEtwDefaultKernelId, kEtwDnsStartId, kEtwDnsStopId to follow kPascalCase per OSQUERY-008, matching the existing kEtwDNSPublisherName convention. Since these are declared but unused within this header (per the finding), no other in-file references needed updating; any external usage in the corresponding .cpp file (not provided) would need matching updates, which is unverified here.

πŸ€– Prompt for AI agents
In osquery/events/windows/etw/etw_publisher_dns.h around line 49, review and complete this code-review fix: File-scope constant kEtwDNSPublisherName is fine, but etwDefaultKernelID/etwDNSStartID/etwDNSStopID break kPascalCase and are unused static member constants.
What the draft fix changed: Renamed the static class constants in EtwPublisherDNS (etw_publisher_dns.h) from `etwDefaultKernelID`, `etwDNSStartID`, `etwDNSStopID` to `kEtwDefaultKernelId`, `kEtwDnsStartId`, `kEtwDnsStopId` to follow kPascalCase per OSQUERY-008, matching the existing `kEtwDNSPublisherName` convention. Since these are declared but unused within this header (per the finding), no other in-file references needed updating; any external usage in the corresponding .cpp file (not provided) would need matching updates, which is unverified here.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟑 85 medium β€” react πŸ‘/πŸ‘Ž to teach the reviewer

static const USHORT etwDNSStartID = 1;
static const USHORT etwDNSStopID = 2;

/**
* @brief Supported User Start DNS Events versions
*/
const enum class etwUserDNSStartVersion {
Version0 = 0,
Version1,
Version2,
Version3
};

/**
* @brief Supported User Stop DNS Events versions
*/
enum class etwUserDNSStopVersion { Version0 = 0, Version1, Version2 };

/**
* @brief Supported Kernel DNS Events versions
*/
enum class etwKernelDNSVersion { Version3 = 3, Version4 };

/**
* @brief Publisher type declaration
*/
DECLARE_PUBLISHER(kEtwDNSPublisherName);

public:
EtwPublisherDNS();

/**
* @brief Used to configure the ETW providers to listen, along with
* its configuration parameters and processing callbacks.
*
* @return Status of the provider setup process.
*/
Status setUp() override;

private:
/**
* @brief Provides the c-function callback in charge of performing the pre
* processing logic. This is the entry point for the event arriving from the
* ETW OS interface. This callback gets called from the OS for every new ETW
* event. There should be lightweight logic here, with no significant
* performance implications.
*
* @param rawEvent is the RAW ETW event obtained from OS ETW provider. It
* comprises an EVENT_HEADER common to all ETW providers and a UserData field
* with provider-specific content.
* https://learn.microsoft.com/en-us/windows/win32/api/evntcons/ns-evntcons-event_record
*
* @param traceCtx This is a helper class that it is used to parse the ETW
* event manifest when needed.
*/
static void providerPreProcessor(const EVENT_RECORD& rawEvent,
const krabs::trace_context& traceCtx);

/**
* @brief Provides the std::function callback in charge of performing the
* post processing logic. This logic is used to enrich, aggregate and modify
* the event data before dispatching it to the event subscribers.
*/
void providerPostProcessor(const EtwEventDataRef& data) override;

private:
using HardVolumeDriveCollection =
std::unordered_map<std::string, std::string>;
using UsernameBySIDCollection = std::unordered_map<std::string, std::string>;

HardVolumeDriveCollection hardVolumeDrives_;
UsernameBySIDCollection usernamesBySIDs_;
};

} // namespace osquery
/**
* Copyright (c) 2014-present, The osquery authors
*
* This source code is licensed as defined by the LICENSE file found in the
* root directory of this source tree.
*
* SPDX-License-Identifier: (Apache-2.0 OR GPL-2.0-only)
*/

#pragma once

#include <osquery/events/windows/etw/etw_publisher.h>

namespace osquery {

/**
* @brief Subscription details for EtwPublisherDNS events.
*/
struct EtwDNSEventSubContext : public SubscriptionContext {
private:
friend class EtwPublisherDNS;
};

/**
* @brief Event details for EtwPublisherDNS events.
*/
struct EtwDNSEventContext : public EventContext {
EtwEventDataRef data;
};

using EtwDNSEventContextRef = std::shared_ptr<EtwDNSEventContext>;
using EtwDNSEventSubContextRef = std::shared_ptr<EtwDNSEventSubContext>;

/**
* @brief Publisher Name
*/
const std::string kEtwDNSPublisherName = "etw_dns_publisher";

/**
* @brief Implements an EtwPublisher that collects and
* dispatches ETW events with process-start and process-stop OS information.
*/
class EtwPublisherDNS
: public EtwPublisherBase,
public EventPublisher<EtwDNSEventSubContext, EtwDNSEventContext> {
/**
* @brief Publisher constants
*/
static const USHORT kEtwDefaultKernelId = 0;
static const USHORT kEtwDnsStartId = 1;
static const USHORT kEtwDnsStopId = 2;

/**
* @brief Supported User Start DNS Events versions
*/
const enum class etwUserDNSStartVersion {
Version0 = 0,
Version1,
Version2,
Version3
};

/**
* @brief Supported User Stop DNS Events versions
*/
enum class etwUserDNSStopVersion { Version0 = 0, Version1, Version2 };

/**
* @brief Supported Kernel DNS Events versions
*/
enum class etwKernelDNSVersion { Version3 = 3, Version4 };

/**
* @brief Publisher type declaration
*/
DECLARE_PUBLISHER(kEtwDNSPublisherName);

public:
EtwPublisherDNS();

/**
* @brief Used to configure the ETW providers to listen, along with
* its configuration parameters and processing callbacks.
*
* @return Status of the provider setup process.
*/
Status setUp() override;

private:
/**
* @brief Provides the c-function callback in charge of performing the pre
* processing logic. This is the entry point for the event arriving from the
* ETW OS interface. This callback gets called from the OS for every new ETW
* event. There should be lightweight logic here, with no significant
* performance implications.
*
* @param rawEvent is the RAW ETW event obtained from OS ETW provider. It
* comprises an EVENT_HEADER common to all ETW providers and a UserData field
* with provider-specific content.
* https://learn.microsoft.com/en-us/windows/win32/api/evntcons/ns-evntcons-event_record
*
* @param traceCtx This is a helper class that it is used to parse the ETW
* event manifest when needed.
*/
static void providerPreProcessor(const EVENT_RECORD& rawEvent,
const krabs::trace_context& traceCtx);

/**
* @brief Provides the std::function callback in charge of performing the
* post processing logic. This logic is used to enrich, aggregate and modify
* the event data before dispatching it to the event subscribers.
*/
void providerPostProcessor(const EtwEventDataRef& data) override;

private:
using HardVolumeDriveCollection =
std::unordered_map<std::string, std::string>;
using UsernameBySIDCollection = std::unordered_map<std::string, std::string>;

HardVolumeDriveCollection hardVolumeDrives_;
UsernameBySIDCollection usernamesBySIDs_;
};

} // namespace osquery

4 changes: 4 additions & 0 deletions osquery/events/windows/windowseventlogpublisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ double WindowsEventLogPublisher::cosineSimilarity(
std::vector<double> buffer_freqs(kCharFreqVectorLen, 0.0);

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦩 🟠 cosineSimilarity divides by buffer_size without checking for empty buffer

In WindowsEventLogPublisher::cosineSimilarity (osquery/events/windows/windowseventlogpublisher.cpp), added an early if (buffer_size == 0) { return 0.0; } check right after computing buffer_size = buffer.size() and before the loop that divides by buffer_size, preventing division by zero when buffer is empty, matching the suggested fix exactly.

πŸ€– Prompt for AI agents
In osquery/events/windows/windowseventlogpublisher.cpp around line 208, review and complete this code-review fix: cosineSimilarity divides by buffer_size without checking for empty buffer.
What the draft fix changed: In WindowsEventLogPublisher::cosineSimilarity (osquery/events/windows/windowseventlogpublisher.cpp), added an early `if (buffer_size == 0) { return 0.0; }` check right after computing `buffer_size = buffer.size()` and before the loop that divides by `buffer_size`, preventing division by zero when `buffer` is empty, matching the suggested fix exactly.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟒 95 high β€” react πŸ‘/πŸ‘Ž to teach the reviewer


auto buffer_size = buffer.size();
if (buffer_size == 0) {
return 0.0;
}

for (unsigned char chr : buffer) {
if (chr < kCharFreqVectorLen) {
buffer_freqs[chr] += 1.0 / buffer_size;
Expand Down
4 changes: 3 additions & 1 deletion osquery/extensions/extensions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,9 @@ Status extensionPathActive(const std::string& path, bool use_timeout = false) {
// Create a client with a 10-second receive timeout.
ExtensionManagerClient client(path, 10);
auto status = client.ping();
return Status::success();
if (status.ok()) {
return Status::success();
}
} catch (const std::exception& /* e */) {
// Path might exist without a connected extension or extension manager.
}
Comment on lines 184 to 192

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦩 🟠 extensionPathActive swallows client construction/ping exceptions and treats them as success path fallthrough

In extensionPathActive (osquery/extensions/extensions.cpp), the try block now checks the result of client.ping() before reporting success: return Status::success(); is only executed when status.ok() is true. If the ping fails (returns a non-ok Status without throwing), execution falls through past the try/catch to the existing failure path (use_timeout check and return Status(1, "Extension socket not available: " + path)), correctly reflecting a failed ping instead of masking it as success. No other logic, signatures, or callers were touched.

πŸ€– Prompt for AI agents
In osquery/extensions/extensions.cpp around line 180, review and complete this code-review fix: extensionPathActive swallows client construction/ping exceptions and treats them as success path fallthrough.
What the draft fix changed: In extensionPathActive (osquery/extensions/extensions.cpp), the try block now checks the result of `client.ping()` before reporting success: `return Status::success();` is only executed when `status.ok()` is true. If the ping fails (returns a non-ok Status without throwing), execution falls through past the try/catch to the existing failure path (`use_timeout` check and `return Status(1, "Extension socket not available: " + path)`), correctly reflecting a failed ping instead of masking it as success. No other logic, signatures, or callers were touched.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟒 92 high β€” react πŸ‘/πŸ‘Ž to teach the reviewer

Expand Down
22 changes: 20 additions & 2 deletions osquery/filesystem/file_compression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,15 @@ Status archive(const std::set<boost::filesystem::path>& paths,
archive_entry_set_size(entry, pFile.size());
archive_entry_set_filetype(entry, AE_IFREG);
archive_entry_set_perm(entry, 0644);

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦩 🟠 archive() ignores archive_write_header/archive_write_data return codes, can silently produce truncated/corrupt tar archives

In archive(), the return values of archive_write_header() and archive_write_data() are now checked. archive_write_header()'s result is checked for ARCHIVE_FATAL/ARCHIVE_WARN, and archive_write_data()'s result is checked for a negative value or a byte count less than the requested block size; on either failure the entry/archive handles are freed and a failure Status with the libarchive error string (via archive_error_string()) is returned instead of silently continuing and returning Status::success().

πŸ€– Prompt for AI agents
In osquery/filesystem/file_compression.cpp around line 184, review and complete this code-review fix: archive() ignores archive_write_header/archive_write_data return codes, can silently produce truncated/corrupt tar archives.
What the draft fix changed: In archive(), the return values of archive_write_header() and archive_write_data() are now checked. archive_write_header()'s result is checked for ARCHIVE_FATAL/ARCHIVE_WARN, and archive_write_data()'s result is checked for a negative value or a byte count less than the requested block size; on either failure the entry/archive handles are freed and a failure Status with the libarchive error string (via archive_error_string()) is returned instead of silently continuing and returning Status::success().
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟑 85 medium β€” react πŸ‘/πŸ‘Ž to teach the reviewer

archive_write_header(arch, entry);
auto headerRet = archive_write_header(arch, entry);
if (headerRet == ARCHIVE_FATAL || headerRet == ARCHIVE_WARN) {
std::string errMsg = "Failed to write tar header for file: " +
f.string() + " (" +
std::string(archive_error_string(arch)) + ")";
archive_entry_free(entry);
archive_write_free(arch);
return Status(1, errMsg);
}

auto blkCount = static_cast<size_t>(ceil(static_cast<double>(pFile.size()) /
static_cast<double>(block_size)));
Expand All @@ -193,11 +201,21 @@ Status archive(const std::set<boost::filesystem::path>& paths,
// resize the buffer to size we read as last block is likely smaller
block.resize(static_cast<std::size_t>(r));
}
archive_write_data(arch, block.data(), block.size());
auto writeRet = archive_write_data(arch, block.data(), block.size());
if (writeRet < 0 ||
static_cast<std::size_t>(writeRet) != block.size()) {
std::string errMsg = "Failed to write tar data for file: " +
f.string() + " (" +
std::string(archive_error_string(arch)) + ")";
archive_entry_free(entry);
archive_write_free(arch);
return Status(1, errMsg);
}
}
archive_entry_free(entry);
}
archive_write_free(arch);
return Status::success();
};
} // namespace osquery

Loading
Loading