zig icon indicating copy to clipboard operation
zig copied to clipboard

Missing null terminator on various kernel32 signatures

Open Pyrolistical opened this issue 1 year ago • 0 comments

Zig Version

0.13.0-dev.75+5c9eb4081

Mismatched signatures

  1. GetCurrentDirectoryW https://github.com/ziglang/zig/blob/084c2cd90f79d5e7edf76b7ddd390adb95a27f0c/lib/std/os/windows/kernel32.zig#L178 lpBuffer should be null-terminated according to https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-getcurrentdirectory
  2. FormatMessageW https://github.com/ziglang/zig/blob/084c2cd90f79d5e7edf76b7ddd390adb95a27f0c/lib/std/os/windows/kernel32.zig#L160 lpBuffer should be null-terminated according to https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-formatmessagew
  3. GetEnvironmentVariableW https://github.com/ziglang/zig/blob/084c2cd90f79d5e7edf76b7ddd390adb95a27f0c/lib/std/os/windows/kernel32.zig#L189 lpBuffer should be null-terminated according to https://learn.microsoft.com/en-us/windows/win32/api/processenv/nf-processenv-getenvironmentvariablew
  4. GetModuleFileNameW https://github.com/ziglang/zig/blob/084c2cd90f79d5e7edf76b7ddd390adb95a27f0c/lib/std/os/windows/kernel32.zig#L199 lpFilename should be null-terminated according to https://learn.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-getmodulefilenamew
  5. GetFullPathNameW https://github.com/ziglang/zig/blob/084c2cd90f79d5e7edf76b7ddd390adb95a27f0c/lib/std/os/windows/kernel32.zig#L220-L225 lpBuffer should be null-terminated according to https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getfullpathnamew

Fixing these would be a breaking change.

Expected Behavior

extern signatures should be correct

Pyrolistical avatar May 12 '24 03:05 Pyrolistical