The nusers variable could, in theory, overflow and trigger an out of
boundary access if a huge amount of entries is added. Realistically,
this is not possible with current systems because way too much data
would be involved.
But let's better be safe than sorry and use correct data types.
Reviewed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
#include <getopt.h>
#include <ctype.h>
#include <errno.h>
+#include <stddef.h>
#include <stdint.h>
#include <string.h>
intmax_t *lines = NULL;
char **usernames = NULL;
char **passwords = NULL;
- unsigned int nusers = 0;
+ size_t nusers = 0;
#endif /* USE_PAM */
log_set_progname(Prog);
sssd_flush_cache (SSSD_DB_PASSWD | SSSD_DB_GROUP);
#ifdef USE_PAM
- unsigned int i;
/* Now update the passwords using PAM */
- for (i = 0; i < nusers; i++) {
+ for (size_t i = 0; i < nusers; i++) {
if (do_pam_passwd_non_interactive ("newusers", usernames[i], passwords[i]) != 0) {
fprintf (stderr,
_("%s: (line %jd, user %s) password not changed\n"),