Skip to content

[UDFS] Initialize all local variables to prevent 0xCCCCCCCC in MSVC debug builds#23

Open
Zero3K20 wants to merge 7 commits into
assorted:udf-devfrom
Zero3K20:copilot/udfs-fix-code
Open

[UDFS] Initialize all local variables to prevent 0xCCCCCCCC in MSVC debug builds#23
Zero3K20 wants to merge 7 commits into
assorted:udf-devfrom
Zero3K20:copilot/udfs-fix-code

Conversation

@Zero3K20
Copy link
Copy Markdown

MSVC debug builds fill uninitialized stack variables with 0xCCCCCCCC. In kernel drivers this is dangerous: an uninitialized BOOLEAN reads as TRUE (non-zero), causing _SEH2_FINALLY cleanup blocks to release locks or resources that were never acquired.

Changes

  • NTSTATUS variables: initialized to STATUS_SUCCESS
  • BOOLEAN flags: initialized to FALSE
  • ULONG counters/sizes: initialized to 0
  • Pointer variables: initialized to NULL

Covers 31 files across the driver (cleanup.cpp, create.cpp, fileinfo.cpp, fscntrl.cpp, misc.cpp, read.cpp, write.cpp, udf_info/dirtree.cpp, udf_info/extent.cpp, udf_info/mount.cpp, udf_info/udf_info.cpp, and others) as well as the support libraries in the Include/ directory (Sys_spec_lib.cpp, phys_lib.cpp, regtools.cpp, mem_tools.cpp, string_lib.cpp).

Notable bug-class fixes

Acquisition flags in _SEH2_FINALLY blocks — if 0xCCCCCCCC, these appear TRUE and release resources never acquired:

// Before
BOOLEAN Acquired;
Acquired = UDFAcquireResourceExclusiveWithCheck(...);
// ...
_SEH2_FINALLY {
    if (Acquired)  // 0xCCCCCCCC == TRUE if exception before assignment
        UDFReleaseResource(...);
}

// After
BOOLEAN Acquired = FALSE;

UDFSetRenameInfo countersDirRefCount, FileInfoRefCount, IgnoreCase, UseClose used in loop logic before guaranteed assignment.

Include/ support librariesNTSTATUS return values, BOOLEAN status flags, ULONG loop/search variables, and pointer variables in phys_lib.cpp, regtools.cpp, mem_tools.cpp, Sys_spec_lib.cpp, and string_lib.cpp.

@Zero3K20 Zero3K20 changed the base branch from write to udf-dev April 27, 2026 06:04
assorted and others added 4 commits April 27, 2026 02:06
Initialize all uninitialized local variables in the UDFS driver to
prevent MSVC debug builds from filling them with 0xCCCCCCCC:
- NTSTATUS/NTSTATUS variables initialized to STATUS_SUCCESS
- BOOLEAN variables initialized to FALSE
- ULONG/pointer variables initialized to 0/NULL

Also restore accidentally removed code:
- if (!FileInfo) check in UDFIndexDirectory (dirtree.cpp)
- PUDF_FILE_INFO curFileInfo declaration in UDFPackDirectory__ (dirtree.cpp)
- PAGED_CODE() calls in misc.cpp and volinfo.cpp
- Comment in misc.cpp AcquireResource function

Agent-Logs-Url: https://github.com/Zero3K20/reactos/sessions/901376db-4acd-42eb-8122-cce62735117e

Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
Initialize all uninitialized local variables in the Include/ support
files: Sys_spec_lib.cpp, phys_lib.cpp, regtools.cpp, mem_tools.cpp,
string_lib.cpp. Covers NTSTATUS, BOOLEAN, ULONG, and pointer variables.

Agent-Logs-Url: https://github.com/Zero3K20/reactos/sessions/a5f32228-fa19-4fba-bf7a-cdde18e904ec

Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
@Zero3K20 Zero3K20 force-pushed the copilot/udfs-fix-code branch from 7459fd0 to 39968cb Compare April 27, 2026 06:06
@Zero3K20 Zero3K20 closed this Apr 27, 2026
@Zero3K20 Zero3K20 reopened this May 21, 2026
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.

3 participants