From 1640e9e6a161bcdd9c3fd704f9047dcf3b259aee Mon Sep 17 00:00:00 2001 From: Nick Peng Date: Sat, 24 Sep 2022 20:14:00 +0800 Subject: [PATCH] smartdns: fix kernel dmesg warnings --- src/smartdns.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/smartdns.c b/src/smartdns.c index 877a6e6..b038f71 100644 --- a/src/smartdns.c +++ b/src/smartdns.c @@ -81,6 +81,11 @@ static int get_uid_gid(int *uid, int *gid) goto out; } + if (result == NULL) { + ret = -1; + goto out; + } + *uid = result->pw_uid; *gid = result->pw_gid; @@ -96,7 +101,11 @@ static int drop_root_privilege(void) { struct __user_cap_data_struct cap; struct __user_cap_header_struct header; +#ifdef _LINUX_CAPABILITY_VERSION_3 + header.version = _LINUX_CAPABILITY_VERSION_3; +#else header.version = _LINUX_CAPABILITY_VERSION; +#endif header.pid = 0; int uid = 0; int gid = 0;