mirror of
https://github.com/openharmony/third_party_libfuse.git
synced 2026-07-19 21:43:34 -04:00
fusermount: Check for argv[0] being present (#577)
It is perfectly legal to execute a program with argc == 0 and therefore no argv. fusermount needs to check for this case, otherwise it will pass a NULL poiunter to strdup() and cause undefined behavior. Especially since fusermount is setuid root, we need to extra be careful. Signed-off-by: Richard Weinberger <richard@nod.at>
This commit is contained in:
committed by
GitHub
parent
272e8447b2
commit
c041da9d41
+1
-1
@@ -1270,7 +1270,7 @@ int main(int argc, char *argv[])
|
||||
{"version", no_argument, NULL, 'V'},
|
||||
{0, 0, 0, 0}};
|
||||
|
||||
progname = strdup(argv[0]);
|
||||
progname = strdup(argc > 0 ? argv[0] : "fusermount");
|
||||
if (progname == NULL) {
|
||||
fprintf(stderr, "%s: failed to allocate memory\n", argv[0]);
|
||||
exit(1);
|
||||
|
||||
Reference in New Issue
Block a user