Here's an example of someone citing a disagreement between CRT and shell32:
https://github.com/rust-lang/rust/issues/44650
This in addition to the Rust CVE mentioned elsewhere in the thread which was rooted in this issue:
https://blog.rust-lang.org/2024/04/09/cve-2024-24576.html
Here are some quick programs to test contrasting approaches. I don't have examples of inputs where they parse differently on hand right now, but I know they exist. This was also a problem that was frequently discussed internally when I worked at MSFT.
#include <stdio.h>
int main(int argc, char **argv)
{
for (int i=0; i<argc; ++i)
puts(argv[i]);
return 0;
}
#pragma comment(lib, "shell32.lib")
#include <windows.h>
#include <stdio.h>
int main()
{
PCWSTR cmdLine = GetCommandLineW();
if (cmdLine)
{
int argc = 0;
PWSTR *argv = CommandLineToArgvW(cmdLine, &argc);
if (argv)
{
for (int i=0; i<argc; ++i)
printf("%ls\n", argv[i]);
LocalFree(argv);
return 0;
}
}
return 1;
}