The members of struct utmp are marked as nonstring. This means they
might not be nil-terminated.
Found by covscan.
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Richard Sharpe <realrichardsharpe@gmail.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
for (i = 0; i < num_users; i++) {
/* getutxent can return multiple user entries for the
* same user, so ignore any dups */
- if (strcmp(u->ut_user, usr_infos[i].name) == 0) {
+ int cmp = strncmp(u->ut_user, usr_infos[i].name, sizeof(u->ut_user));
+ if (cmp == 0) {
break;
}
}