Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions contrib/windows_kernel/libc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ struct MEMBLOCK
size_t size;
#pragma warning(push)
#pragma warning (disable : 4200)
__declspec(align(MEMORY_ALLOCATION_ALIGNMENT))
char data[0];
#pragma warning(pop)
};
Expand Down
6 changes: 3 additions & 3 deletions windows/winkernel_mm.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ static const ULONG CS_WINKERNEL_POOL_TAG = 'kwsC';
// A structure to implement realloc()
typedef struct _CS_WINKERNEL_MEMBLOCK {
size_t size; // A number of bytes allocated
char data[1]; // An address returned to a caller
__declspec(align(MEMORY_ALLOCATION_ALIGNMENT))
char data[ANYSIZE_ARRAY]; // An address returned to a caller
} CS_WINKERNEL_MEMBLOCK;
C_ASSERT(sizeof(CS_WINKERNEL_MEMBLOCK) == sizeof(void *) * 2);


// free()
Expand All @@ -39,7 +39,7 @@ void * CAPSTONE_API cs_winkernel_malloc(size_t size)
// A specially crafted size value can trigger the overflow.
// If the sum in a value that overflows or underflows the capacity of the type,
// the function returns NULL.
if (!NT_SUCCESS(RtlSizeTAdd(size, sizeof(CS_WINKERNEL_MEMBLOCK), &number_of_bytes))) {
if (!NT_SUCCESS(RtlSizeTAdd(size, FIELD_OFFSET(CS_WINKERNEL_MEMBLOCK, data), &number_of_bytes))) {
return NULL;
}
block = (CS_WINKERNEL_MEMBLOCK *)ExAllocatePoolWithTag(
Expand Down