diff options
author | richardweinberger <richard@nod.at> | 2021-01-08 11:07:02 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-08 10:07:02 +0000 |
commit | 699ab32b5dbaf44d715aa08aa21d1ec62e479d2b (patch) | |
tree | 5a28550f768215a420908101d3227cd4424980dd | |
parent | ccba27fbec00d253102395cbdab048f0553c1938 (diff) | |
download | fuse-699ab32b5dbaf44d715aa08aa21d1ec62e479d2b.tar.gz |
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>
-rw-r--r-- | util/fusermount.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/util/fusermount.c b/util/fusermount.c index 45e96bc..243d25e 100644 --- a/util/fusermount.c +++ b/util/fusermount.c @@ -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); |