Handling argc==0 in the kernel
Handling argc==0 in the kernel
Posted Jan 28, 2022 16:35 UTC (Fri) by larkey (guest, #104463)In reply to: Handling argc==0 in the kernel by matthias
Parent article: Handling argc==0 in the kernel
> Yeah, but disallowing the former and allowing the latter does not make any sense, as the two cases cannot be distinguished by the called application. There would be no advantage from just disallowing argv == NULL.
>
> The problematic case from the security persepctive is allowing argv[0] == NULL (or more precisely argc==0). The problematic case from the compatibility perspective is disallowing argv == NULL in the execve() call. Thus only disallowing argv == NULL in the call gives us the worst from both perspectives. We get all compatibility problems with no increase in security.
I disagree here though. Disallowing argv == NULL but allowing argv[0] == NULL would allow for this "iterator" pattern (which is as old as UNIX):
for (**arg = &argv[1]; arg < &argv[argc]; arg++)
The LWN site is currently under high scraper load, so comment display has been suppressed for anonymous users. If you are a human, you may read the comments by clicking the button below:
Note: you can avoid this step in the future by logging into your LWN account.
