kaoh / globalplatform

C library + command-line for Open- / GlobalPlatform smart cards
https://kaoh.github.io/globalplatform/
Other
72 stars 30 forks source link

Heap corruption in OPGP_log_Hex on Windows #21

Closed kaoh closed 4 years ago

kaoh commented 4 years ago

MSVC compiler builds products with UNICODE macro enabled by default so each symbol is 2 bytes width. It is handled in OPGP_log_Hex function (globalplatform/src/debug.c:57) except the fact that null-terminator is also 2 bytes width if UNICODE macro is defined. A buffer for the message must be size (bufferLength * 2 + 1) * sizeof(TCHAR) bytes.

Reported by: undef-behavior

kaoh commented 4 years ago

Thanks for reporting this. Please check the latest commit from trunk if this is fixed for you.

Original comment by: kaoh

kaoh commented 4 years ago

Thank you for a quick fix! This is worked for me on the latest master.

Original comment by: undef-behavior

kaoh commented 4 years ago

Original comment by: kaoh