Skip to content

Migrate raw pointers to unique_ptr and fix memory/stability issues#38

Open
crayy8 wants to merge 4 commits intoSleuthKitLabs:develop-4.14from
crayy8:rejistry_updates
Open

Migrate raw pointers to unique_ptr and fix memory/stability issues#38
crayy8 wants to merge 4 commits intoSleuthKitLabs:develop-4.14from
crayy8:rejistry_updates

Conversation

@crayy8
Copy link
Copy Markdown
Member

@crayy8 crayy8 commented Mar 24, 2026

  • Replace raw pointer ownership with unique_ptr throughout the library: RegistryByteBuffer, ValueData, RegistryKey, RegistryValue, RegistryHiveFile, RegistryHiveBuffer, Cell, HBIN, REGFHeader, NKRecord, VKRecord, ValueListRecord
  • Remove AutoCellPtrList and AutoHBINPtrList RAII wrappers now that unique_ptr handles lifetime automatically
  • Add virtual destructor to BinaryBlock to prevent UB when deleting through base class pointer
  • Fix integer overflow in ByteBuffer::read() bounds check via uint64_t cast
  • Fix dangling pointer in RejistryException::what() by caching result in mutable member
  • Fix RegistryHiveFile::getErrorMessage() to handle FormatMessageA failure
  • Fix REGFHeader::getHBINs() to std::move unique_ptr into vector
  • Refactor Rejistry test program to exercise both RegistryHiveFile and RegistryHiveBuffer through shared processRegistryHive() function

- Replace raw pointer ownership with unique_ptr throughout the library:
  RegistryByteBuffer, ValueData, RegistryKey, RegistryValue,
  RegistryHiveFile, RegistryHiveBuffer, Cell, HBIN, REGFHeader,
  NKRecord, VKRecord, ValueListRecord
- Remove AutoCellPtrList and AutoHBINPtrList RAII wrappers now that
  unique_ptr handles lifetime automatically
- Add virtual destructor to BinaryBlock to prevent UB when deleting
  through base class pointer
- Fix integer overflow in ByteBuffer::read() bounds check via uint64_t cast
- Fix dangling pointer in RejistryException::what() by caching result
  in mutable member
- Fix RegistryHiveFile::getErrorMessage() to handle FormatMessageA failure
- Fix REGFHeader::getHBINs() to std::move unique_ptr into vector
- Refactor Rejistry test program to exercise both RegistryHiveFile and
  RegistryHiveBuffer through shared processRegistryHive() function
crayy8 added 3 commits March 24, 2026 11:21
- Replace raw pointer typedefs with unique_ptr equivalents across
  NKRecord, VKRecord, HBIN, SubkeyListRecord, ValueListRecord,
  RegistryKey, RegistryValue, ValueData, and RegistryHive
- Remove AutoNKRecordPtrList and AutoVKRecordPtrList RAII wrappers
- Return unique_ptr from getRoot(), getSubkeyList(), getValueList(),
  getValue(), getSubkeys(), and getValues() throughout the hierarchy
- Add bounds check in HBIN::getCells() to prevent over-reading hbin
- Delete copy assignment operators on Buffer and Record base classes
- Replace NULL with nullptr in HBIN and RegistryByteBuffer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants