Merge pull request #362 from ikerexxe/buffer_size

Fix covscan BUFFER_SIZE
This commit is contained in:
Serge Hallyn 2021-06-22 20:55:31 -05:00 committed by GitHub
commit d4535015a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 7 deletions

View File

@ -98,7 +98,7 @@ void failure (uid_t uid, const char *tty, struct faillog *fl)
fl->fail_cnt++; fl->fail_cnt++;
} }
strncpy (fl->fail_line, tty, sizeof fl->fail_line); strncpy (fl->fail_line, tty, sizeof (fl->fail_line) - 1);
(void) time (&fl->fail_time); (void) time (&fl->fail_time);
/* /*

View File

@ -100,9 +100,9 @@ void dolastlog (
ll_time = newlog.ll_time; ll_time = newlog.ll_time;
(void) time (&ll_time); (void) time (&ll_time);
newlog.ll_time = ll_time; newlog.ll_time = ll_time;
strncpy (newlog.ll_line, line, sizeof newlog.ll_line); strncpy (newlog.ll_line, line, sizeof (newlog.ll_line) - 1);
#if HAVE_LL_HOST #if HAVE_LL_HOST
strncpy (newlog.ll_host, host, sizeof newlog.ll_host); strncpy (newlog.ll_host, host, sizeof (newlog.ll_host) - 1);
#endif #endif
if ( (lseek (fd, offset, SEEK_SET) != offset) if ( (lseek (fd, offset, SEEK_SET) != offset)
|| (write (fd, (const void *) &newlog, sizeof newlog) != (ssize_t) sizeof newlog) || (write (fd, (const void *) &newlog, sizeof newlog) != (ssize_t) sizeof newlog)

View File

@ -257,25 +257,25 @@ static void updwtmpx (const char *filename, const struct utmpx *utx)
utent->ut_type = USER_PROCESS; utent->ut_type = USER_PROCESS;
#endif /* HAVE_STRUCT_UTMP_UT_TYPE */ #endif /* HAVE_STRUCT_UTMP_UT_TYPE */
utent->ut_pid = getpid (); utent->ut_pid = getpid ();
strncpy (utent->ut_line, line, sizeof (utent->ut_line)); strncpy (utent->ut_line, line, sizeof (utent->ut_line) - 1);
#ifdef HAVE_STRUCT_UTMP_UT_ID #ifdef HAVE_STRUCT_UTMP_UT_ID
if (NULL != ut) { if (NULL != ut) {
strncpy (utent->ut_id, ut->ut_id, sizeof (utent->ut_id)); strncpy (utent->ut_id, ut->ut_id, sizeof (utent->ut_id));
} else { } else {
/* XXX - assumes /dev/tty?? */ /* XXX - assumes /dev/tty?? */
strncpy (utent->ut_id, line + 3, sizeof (utent->ut_id)); strncpy (utent->ut_id, line + 3, sizeof (utent->ut_id) - 1);
} }
#endif /* HAVE_STRUCT_UTMP_UT_ID */ #endif /* HAVE_STRUCT_UTMP_UT_ID */
#ifdef HAVE_STRUCT_UTMP_UT_NAME #ifdef HAVE_STRUCT_UTMP_UT_NAME
strncpy (utent->ut_name, name, sizeof (utent->ut_name)); strncpy (utent->ut_name, name, sizeof (utent->ut_name));
#endif /* HAVE_STRUCT_UTMP_UT_NAME */ #endif /* HAVE_STRUCT_UTMP_UT_NAME */
#ifdef HAVE_STRUCT_UTMP_UT_USER #ifdef HAVE_STRUCT_UTMP_UT_USER
strncpy (utent->ut_user, name, sizeof (utent->ut_user)); strncpy (utent->ut_user, name, sizeof (utent->ut_user) - 1);
#endif /* HAVE_STRUCT_UTMP_UT_USER */ #endif /* HAVE_STRUCT_UTMP_UT_USER */
if (NULL != hostname) { if (NULL != hostname) {
struct addrinfo *info = NULL; struct addrinfo *info = NULL;
#ifdef HAVE_STRUCT_UTMP_UT_HOST #ifdef HAVE_STRUCT_UTMP_UT_HOST
strncpy (utent->ut_host, hostname, sizeof (utent->ut_host)); strncpy (utent->ut_host, hostname, sizeof (utent->ut_host) - 1);
#endif /* HAVE_STRUCT_UTMP_UT_HOST */ #endif /* HAVE_STRUCT_UTMP_UT_HOST */
#ifdef HAVE_STRUCT_UTMP_UT_SYSLEN #ifdef HAVE_STRUCT_UTMP_UT_SYSLEN
utent->ut_syslen = MIN (strlen (hostname), utent->ut_syslen = MIN (strlen (hostname),