6 ms·
OpenBSD has handled this case for some years. I do not know if there was any breakage or fallout from this. https://github.com/openbsd/src/commit/7421256387006
by mortenlarsen 5y ago
OpenBSD has handled this case for some years. I do not know if there was any breakage or fallout from this.
https://github.com/openbsd/src/commit/74212563870067f5b1e271876e1ec5a2fdf2f2e0 https://github.com/openbsd/src/commit/74212563870067f5b1e271...
- simcop2387 5y agoThat's not a bad precedent for saying it shouldn't break much of anything if it's done. I also love the name of the label for handling the error condition there.
- cozzyd 5y agoSlightly funnier would be "harmful"
- sedatk 5y agoFWIW, Windows (MSVC) also guarantees "argc > 0" and non-empty argv with non-empty argv[0]. It also returns EINVAL if execve validation fails.
- garaetjjte 5y agoWindows doesn't have argv at all, it uses single string as cmdline arguments.
- sedatk 5y agoThe C runtime bridges that gap. https://docs.microsoft.com/en-us/cpp/cpp/main-function-command-line-args?view=msvc-170#standard-command-line-arguments https://docs.microsoft.com/en-us/cpp/cpp/main-function-comma...
- asveikau 5y agoAt the kernel level, yes. But they are talking about CRT, which parses the command line and makes argv from user space, if your linker is set up to have a main() and not WinMain. That is why they put MSVC in parens.
- roastedpeacock 5y agoThanks for answering my next question, how much world of hurt would be involved with this solution in terms of breaking userspace. Kind of insane how Linux kernel developers didn't test and resolve this in a similar manner before this became an issue.
- gnubison 5y agoargc==0 is a well known part of the API, even if not everyone handles it correctly. I guarantee that >95% of kernel developers (if not 100% of them) understand this design and its flaws.
- throw0101a 5y ago> OpenBSD has handled this case for some years. I do not know if there was any breakage or fallout from this. The other thing about OpenBSD is that when they make a change to their OS, they also go through to make sure all the (third-party) ports/packages: * https://cvsweb.openbsd.org/ports/ https://cvsweb.openbsd.org/ports/ * https://github.com/openbsd/ports https://github.com/openbsd/ports do not break. So they're create patches for the software and and submit them upstream.