2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-31 14:25:15 +00:00

Don't print a NULL as a string if role/type/privs/limitprivs is not set.

We can't rely on printf("%s", NULL) not crashing.
This commit is contained in:
Todd C. Miller
2021-02-18 06:09:08 -07:00
parent aaf3d5643b
commit 5813358b2b

View File

@@ -203,8 +203,10 @@ apply_cmndspec(struct cmndspec *cs)
user_role = def_role;
def_role = NULL;
}
sudo_debug_printf(SUDO_DEBUG_INFO|SUDO_DEBUG_LINENO,
"user_role -> %s", user_role);
if (user_role != NULL) {
sudo_debug_printf(SUDO_DEBUG_INFO|SUDO_DEBUG_LINENO,
"user_role -> %s", user_role);
}
}
if (user_type == NULL) {
if (cs->type != NULL) {
@@ -218,8 +220,10 @@ apply_cmndspec(struct cmndspec *cs)
user_type = def_type;
def_type = NULL;
}
sudo_debug_printf(SUDO_DEBUG_INFO|SUDO_DEBUG_LINENO,
"user_type -> %s", user_type);
if (user_type != NULL) {
sudo_debug_printf(SUDO_DEBUG_INFO|SUDO_DEBUG_LINENO,
"user_type -> %s", user_type);
}
}
#endif /* HAVE_SELINUX */
#ifdef HAVE_PRIV_SET
@@ -236,8 +240,10 @@ apply_cmndspec(struct cmndspec *cs)
runas_privs = def_privs;
def_privs = NULL;
}
sudo_debug_printf(SUDO_DEBUG_INFO|SUDO_DEBUG_LINENO,
"runas_privs -> %s", runas_privs);
if (runas_privs != NULL) {
sudo_debug_printf(SUDO_DEBUG_INFO|SUDO_DEBUG_LINENO,
"runas_privs -> %s", runas_privs);
}
}
if (runas_limitprivs == NULL) {
if (cs->limitprivs != NULL) {
@@ -251,8 +257,10 @@ apply_cmndspec(struct cmndspec *cs)
runas_limitprivs = def_limitprivs;
def_limitprivs = NULL;
}
sudo_debug_printf(SUDO_DEBUG_INFO|SUDO_DEBUG_LINENO,
"runas_limitprivs -> %s", runas_limitprivs);
if (runas_limitprivs != NULL) {
sudo_debug_printf(SUDO_DEBUG_INFO|SUDO_DEBUG_LINENO,
"runas_limitprivs -> %s", runas_limitprivs);
}
}
#endif /* HAVE_PRIV_SET */
if (cs->timeout > 0) {