Some programs have a static char *program_name that is used for usage synopses in the event that they're invoked incorrectly. This is done with consideration for how the particular program functions, for instance, npc(1) doesn't have this because an empty argv would be fine as it only needs to process standard input and standard output. But utilities like str(1) and strcmp(1) do have this because arguments are necessary in order for them to have something to do; absent arguments are incorrect invocation and program_name exists to supply a decent placeholder name for the help text if argv[0] isn't set.
I'm not sure why this would be a problem.
Why would it be desirable to have `argc == 0`?
Some programs have a `static char *program_name` that is used for usage synopses in the event that they're invoked incorrectly. This is done with consideration for how the particular program functions, for instance, npc(1) doesn't have this because an empty argv would be fine as it only needs to process standard input and standard output. But utilities like str(1) and strcmp(1) do have this because arguments are necessary in order for them to have something to do; absent arguments are incorrect invocation and `program_name` exists to supply a decent placeholder name for the help text if argv[0] isn't set.
I'm not sure why this would be a problem.
mostly because if you manage to remove argv[0] you probably meant to, and if you didn’t, it’s a symptom of a larger problem that should probably be reflected in output.
mostly because if you manage to remove argv[0] you probably meant to, and if you didn’t, it’s a symptom of a larger problem that should probably be reflected in output.
I could basically change it to static char *program_name = "<no argv[0]>"; but I figured if argv[0] wasn't set my tools should still work fine as an oasis of functionality among everything else so obviously broken.
Hacks can be dangerous. [Polkit famously had a root escalation vulnerability around assuming `argc > 0`](https://blog.qualys.com/vulnerabilities-threat-research/2022/01/25/pwnkit-local-privilege-escalation-vulnerability-discovered-in-polkits-pkexec-cve-2021-4034). The choices are either to cope without `argv[0]` or do frightening things with `envp` which usually succeeds `argv` in memory.
I could basically change it to `static char *program_name = "<no argv[0]>";` but I figured if `argv[0]` wasn't set my tools should still work fine as an oasis of functionality among everything else so obviously broken.
silt
was assigned by trinity2023-12-26 13:52:15 -07:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
In some cases, it may be desirable for the
argv[0]to be empty in usage. This is currently impossible.Why would it be desirable to have
argc == 0?Some programs have a
static char *program_namethat is used for usage synopses in the event that they're invoked incorrectly. This is done with consideration for how the particular program functions, for instance, npc(1) doesn't have this because an empty argv would be fine as it only needs to process standard input and standard output. But utilities like str(1) and strcmp(1) do have this because arguments are necessary in order for them to have something to do; absent arguments are incorrect invocation andprogram_nameexists to supply a decent placeholder name for the help text if argv[0] isn't set.I'm not sure why this would be a problem.
mostly because if you manage to remove argv[0] you probably meant to, and if you didn’t, it’s a symptom of a larger problem that should probably be reflected in output.
i’m not in the business of preventing fun hacks of our tools, yknow :P
Hacks can be dangerous. Polkit famously had a root escalation vulnerability around assuming
argc > 0. The choices are either to cope withoutargv[0]or do frightening things withenvpwhich usually succeedsargvin memory.I could basically change it to
static char *program_name = "<no argv[0]>";but I figured ifargv[0]wasn't set my tools should still work fine as an oasis of functionality among everything else so obviously broken.Tagged because you might have something to add, I think we've probably discussed
argc==0before.