mirror of
https://github.com/libfuse/libfuse.git
synced 2024-11-27 22:24:18 +08:00
mount.fuse.c: fix potential accessing NULL pointer
In mount.fuse.c, pwd is set by calling getpwnam func. If the matching entry is not found or an error occurs in getpwnam func, pwd will be NULL. So we need to check whether pwd is NULL before accessing it. Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com> Signed-off-by: Haotian Li <lihaotian9@huawei.com>
This commit is contained in:
parent
d614415a0c
commit
8b318a7ed6
@ -398,7 +398,7 @@ int main(int argc, char *argv[])
|
||||
#endif
|
||||
|
||||
struct passwd *pwd = getpwnam(setuid_name);
|
||||
if (setgid(pwd->pw_gid) == -1 || setuid(pwd->pw_uid) == -1) {
|
||||
if (!pwd || setgid(pwd->pw_gid) == -1 || setuid(pwd->pw_uid) == -1) {
|
||||
fprintf(stderr, "%s: Failed to setuid to %s: %s\n",
|
||||
progname, setuid_name, strerror(errno));
|
||||
exit(1);
|
||||
|
Loading…
Reference in New Issue
Block a user