Minor snprintf() usage tweaks:

1) don't assume snprintf() returns -1 on error, check for <0
2) when comparing return value of sizeof(foo), cast the sizeof, not the len
3) cast return value to void in cases where snprintf cannot fail
This commit is contained in:
Todd C. Miller
2019-01-20 07:49:48 -07:00
parent 3d63eee344
commit 985600e7f0
26 changed files with 139 additions and 124 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2016, 2018 Todd C. Miller <Todd.Miller@sudo.ws>
* Copyright (c) 2013, 2016, 2018-2018 Todd C. Miller <Todd.Miller@sudo.ws>
*
* This code is derived from software contributed by Aaron Spangler.
*
@@ -412,7 +412,7 @@ sudo_ldap_role_to_priv(const char *cn, void *hosts, void *runasusers,
size_t slen = sizeof("sudoRole") + strlen(priv->ldap_role);
if ((source = rcstr_alloc(slen)) == NULL)
goto oom;
snprintf(source, slen, "sudoRole %s", priv->ldap_role);
(void)snprintf(source, slen, "sudoRole %s", priv->ldap_role);
}
while ((opt = iter(&opts)) != NULL) {