|
|
|
|
|
by gwbas1c
660 days ago
|
|
I agree, I think the author really shot themselves in the foot when they, at length, criticized the merits of a program using argv[0]. The real point are the security flaws in a calling program setting argv[0], because it really, really should be set by the operating system. (As a programmer, I shouldn't have to defend against these kinds of attacks. The OS should block it.) The criticisms of valid programming practices, IMO, hurt the author's credibility and distract from the real point of the article. |
|
argv[0] was designed to be part of the arguments to the program, and it succeeds perfectly at that task. The problem is that it has been abused by external tools as a way to identify the program just because there was no other alternative.
It has to be writable because the entire argv string (in program memory) is writable and declared as
not and needs to preserve back-compat. Classic C code might be calling strtok on the arguments, so that block of memory needs to remain writable.