Remove asprintf() return value warnings.
This commit is contained in:
@@ -1161,13 +1161,15 @@ done:
|
|||||||
static char *
|
static char *
|
||||||
sudo_ldap_build_default_filter(void)
|
sudo_ldap_build_default_filter(void)
|
||||||
{
|
{
|
||||||
char *filt = NULL;
|
char *filt;
|
||||||
debug_decl(sudo_ldap_build_default_filter, SUDOERS_DEBUG_LDAP)
|
debug_decl(sudo_ldap_build_default_filter, SUDOERS_DEBUG_LDAP)
|
||||||
|
|
||||||
if (ldap_conf.search_filter)
|
if (!ldap_conf.search_filter)
|
||||||
(void)asprintf(&filt, "(&%s(cn=defaults))", ldap_conf.search_filter);
|
debug_return_str(strdup("cn=defaults"));
|
||||||
else
|
|
||||||
filt = strdup("cn=defaults");
|
if (asprintf(&filt, "(&%s(cn=defaults))", ldap_conf.search_filter) == -1)
|
||||||
|
debug_return_str(NULL);
|
||||||
|
|
||||||
debug_return_str(filt);
|
debug_return_str(filt);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1686,8 +1688,9 @@ overflow:
|
|||||||
static char *
|
static char *
|
||||||
sudo_ldap_build_pass2(void)
|
sudo_ldap_build_pass2(void)
|
||||||
{
|
{
|
||||||
char *filt = NULL, timebuffer[TIMEFILTER_LENGTH + 1];
|
char *filt, timebuffer[TIMEFILTER_LENGTH + 1];
|
||||||
bool query_netgroups = def_use_netgroups;
|
bool query_netgroups = def_use_netgroups;
|
||||||
|
int len;
|
||||||
debug_decl(sudo_ldap_build_pass2, SUDOERS_DEBUG_LDAP)
|
debug_decl(sudo_ldap_build_pass2, SUDOERS_DEBUG_LDAP)
|
||||||
|
|
||||||
/* No need to query netgroups if using netgroup_base. */
|
/* No need to query netgroups if using netgroup_base. */
|
||||||
@@ -1711,20 +1714,20 @@ sudo_ldap_build_pass2(void)
|
|||||||
* those get ANDed in to the expression.
|
* those get ANDed in to the expression.
|
||||||
*/
|
*/
|
||||||
if (query_netgroups && def_group_plugin) {
|
if (query_netgroups && def_group_plugin) {
|
||||||
(void)asprintf(&filt, "%s%s(|(sudoUser=+*)(sudoUser=%%:*))%s%s",
|
len = asprintf(&filt, "%s%s(|(sudoUser=+*)(sudoUser=%%:*))%s%s",
|
||||||
(ldap_conf.timed || ldap_conf.search_filter) ? "(&" : "",
|
(ldap_conf.timed || ldap_conf.search_filter) ? "(&" : "",
|
||||||
ldap_conf.search_filter ? ldap_conf.search_filter : "",
|
ldap_conf.search_filter ? ldap_conf.search_filter : "",
|
||||||
ldap_conf.timed ? timebuffer : "",
|
ldap_conf.timed ? timebuffer : "",
|
||||||
(ldap_conf.timed || ldap_conf.search_filter) ? ")" : "");
|
(ldap_conf.timed || ldap_conf.search_filter) ? ")" : "");
|
||||||
} else {
|
} else {
|
||||||
(void)asprintf(&filt, "%s%s(sudoUser=*)(sudoUser=%s*)%s%s",
|
len = asprintf(&filt, "%s%s(sudoUser=*)(sudoUser=%s*)%s%s",
|
||||||
(ldap_conf.timed || ldap_conf.search_filter) ? "(&" : "",
|
(ldap_conf.timed || ldap_conf.search_filter) ? "(&" : "",
|
||||||
ldap_conf.search_filter ? ldap_conf.search_filter : "",
|
ldap_conf.search_filter ? ldap_conf.search_filter : "",
|
||||||
query_netgroups ? "+" : "%:",
|
query_netgroups ? "+" : "%:",
|
||||||
ldap_conf.timed ? timebuffer : "",
|
ldap_conf.timed ? timebuffer : "",
|
||||||
(ldap_conf.timed || ldap_conf.search_filter) ? ")" : "");
|
(ldap_conf.timed || ldap_conf.search_filter) ? ")" : "");
|
||||||
}
|
}
|
||||||
if (filt == NULL)
|
if (len == -1)
|
||||||
sudo_warnx(U_("unable to allocate memory"));
|
sudo_warnx(U_("unable to allocate memory"));
|
||||||
|
|
||||||
debug_return_str(filt);
|
debug_return_str(filt);
|
||||||
|
@@ -428,9 +428,10 @@ static bool
|
|||||||
vlog_warning(int flags, const char *fmt, va_list ap)
|
vlog_warning(int flags, const char *fmt, va_list ap)
|
||||||
{
|
{
|
||||||
int oldlocale, serrno = errno;
|
int oldlocale, serrno = errno;
|
||||||
char *logline, *message = NULL;
|
char *logline, *message;
|
||||||
bool uid_changed, rval = true;
|
bool uid_changed, rval = true;
|
||||||
va_list ap2;
|
va_list ap2;
|
||||||
|
int len;
|
||||||
debug_decl(vlog_error, SUDOERS_DEBUG_LOGGING)
|
debug_decl(vlog_error, SUDOERS_DEBUG_LOGGING)
|
||||||
|
|
||||||
/* Need extra copy of ap for sudo_vwarn()/sudo_vwarnx() below. */
|
/* Need extra copy of ap for sudo_vwarn()/sudo_vwarnx() below. */
|
||||||
@@ -442,12 +443,12 @@ vlog_warning(int flags, const char *fmt, va_list ap)
|
|||||||
/* Expand printf-style format + args (with a special case). */
|
/* Expand printf-style format + args (with a special case). */
|
||||||
if (fmt == INCORRECT_PASSWORD_ATTEMPT) {
|
if (fmt == INCORRECT_PASSWORD_ATTEMPT) {
|
||||||
unsigned int tries = va_arg(ap, unsigned int);
|
unsigned int tries = va_arg(ap, unsigned int);
|
||||||
(void)asprintf(&message, ngettext("%u incorrect password attempt",
|
len = asprintf(&message, ngettext("%u incorrect password attempt",
|
||||||
"%u incorrect password attempts", tries), tries);
|
"%u incorrect password attempts", tries), tries);
|
||||||
} else {
|
} else {
|
||||||
(void)vasprintf(&message, _(fmt), ap);
|
len = vasprintf(&message, _(fmt), ap);
|
||||||
}
|
}
|
||||||
if (message == NULL) {
|
if (len == -1) {
|
||||||
rval = false;
|
rval = false;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user