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

Fix mem leak regression with Windows' sids API #6984

Conversation

mike-myers-tob
Copy link
Member

Closes #6979 fixing a small regression introduced in #6782 that undid part of #6714

It's easy to forget to free memory with "Caller must free this parameter" APIs like ConvertStringSidToSidA, fixed before in #6714 (we even forgot to do it in the wrapper we created for ConvertSidToSidStringA, see #6548 that fixed that).

Because a wrapper for ConvertSidToSidStringA, I found one place that I changed to use that, instead of the raw API, saving a few lines of code. But in the future, to avoid similar problems with ConvertStringSidToSidA, we'd have to make our own wrapper class for sid that implemented RAII as noted by @Breakwell.

@mike-myers-tob mike-myers-tob requested review from a team as code owners March 3, 2021 01:55
@mike-myers-tob mike-myers-tob changed the title Mike/fix mem leak regression windows with sids API Fix mem leak regression windows with sids API Mar 3, 2021
@mike-myers-tob mike-myers-tob changed the title Fix mem leak regression windows with sids API Fix mem leak regression with Windows' sids API Mar 3, 2021
@theopolis
Copy link
Member

we'd have to make our own wrapper class for sid that implemented RAII

Check out the example here, https://github.com/osquery/osquery/blob/master/osquery/tables/system/darwin/mdls.mm#L70 and see if that approach would be workable here.

@mike-myers-tob mike-myers-tob added this to the 4.7.0 milestone Mar 3, 2021
@zwass
Copy link
Member

zwass commented Mar 3, 2021

Great idea @theopolis! I'm a huge fan of scope_guard but had forgotten about it.

@mike-myers-tob mike-myers-tob merged commit 74d6a3e into osquery:master Mar 3, 2021
@mike-myers-tob mike-myers-tob deleted the mike/fix-mem-leak-regression-windows-sids branch March 3, 2021 17:06
aikuchin pushed a commit to aikuchin/osquery that referenced this pull request Jul 11, 2023
…0 to master

* commit '943935789dbfb03b55db1471ed1595e1fd4ffe23': (119 commits)
  seccomp migrations
  Add 4.7.0 CHANGELOG (osquery#6985)
  ATC fails because journal_mode pragma is blocked by sqlite authorizer (osquery#6999)
  Always use BIGINT macro for 'long long' data (osquery#6986)
  chrome_extensions: Refactor the table, add tests (osquery#6780)
  Remove extraneous lenses directory for augues on macOS (osquery#6998)
  Update the info about macOS CI (osquery#6988)
  Make Group ID columns consistent across Windows tables (osquery#6987)
  Fix mem leak regression with Windows' sids API (osquery#6984)
  Fix error in process_open_files around stoi vs stoul (osquery#6983)
  Remove hash and yara table from fuzz harnesses (osquery#6972)
  Augeas Table: Don't autoload system lenses (osquery#6980)
  Augeas Table: Fix output bug (osquery#6981)
  Add concat and concat_ws functions (osquery#6927)
  Copy JSON objects to avoid MemoryPool buildup (osquery#6957)
  Fix CODEOWNERS syntax to allow committers and TSC (osquery#6975)
  augeas: Clear aug pointer on error (osquery#6973)
  Adds support for the computer field in Windows Eventlogs (osquery#6952)
  Add Shellbags table (osquery#6949)
  Implementation of VM metadata table for Yandex.Cloud (osquery#6961)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Leak using ConvertStringSidToSid in Windows users table
3 participants