Skip to content

Wrong format specifier for sizeof #3

Description

@phuclv90

The return type of sizeof is size_t which must be printed using %zu. Technically using the wrong format specifier (%llu in this case) invokes UB

DbgPrint("Short read of read MmPfnDatabase pointer %p as provided by userspace (read %llu of %llu bytes)\n", MmPfnDatabaseUnsafe, bytesRead, sizeof(PVOID));

DbgPrint("Failed to read PFN from PFN database at %p (%p[0x%16llx]): NTSTATUS 0x%08lx, transferred %llu of %llu bytes\n", srcAddress.VirtualAddress, MmPfnDatabase, pfnArray[pfnIdx], s, numRead, sizeof(struct PFN));

https://github.com/countercept/ModuleStomping/blob/56c778b37229606818487b87e96d74b1db858817/driver/driver.c#L195

https://github.com/countercept/ModuleStomping/blob/56c778b37229606818487b87e96d74b1db858817/driver/driver.c#L342

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions