Binaries have preset names when argv[0]
is an empty string
#12
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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_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 andprogram_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.
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 withenvp
which usually succeedsargv
in 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==0
before.