2 ms·
I'm not entirely sure what you're saying is different here. I picked the first MSFT page on argv, https://learn.microsoft.com/en-us/cpp/c-language/parsing-c-co
by dekhn 3y ago
I'm not entirely sure what you're saying is different here.
I picked the first MSFT page on argv, https://learn.microsoft.com/en-us/cpp/c-language/parsing-c-command-line-arguments?view=msvc-170 https://learn.microsoft.com/en-us/cpp/c-language/parsing-c-c... and compiled and ran that program with various command lines, and it does exactly what I expected (argv array members are tokenized according to my quoting).
Could you be clearer, perhaps by posting a simple C example and a few command lines demonstrating what you mean?
- asveikau 3y agoHere's an example of someone citing a disagreement between CRT and shell32: https://github.com/rust-lang/rust/issues/44650 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 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; }