memset(&ut, 0, sizeof(ut));
- strncpy(ut.ut_user,
+ str2memcpy(ut.ut_user,
cxt->username ? cxt->username : "(unknown)",
sizeof(ut.ut_user));
if (cxt->tty_number)
- strncpy(ut.ut_id, cxt->tty_number, sizeof(ut.ut_id));
+ str2memcpy(ut.ut_id, cxt->tty_number, sizeof(ut.ut_id));
if (cxt->tty_name)
- xstrncpy(ut.ut_line, cxt->tty_name, sizeof(ut.ut_line));
+ str2memcpy(ut.ut_line, cxt->tty_name, sizeof(ut.ut_line));
gettimeofday(&tv, NULL);
ut.ut_tv.tv_sec = tv.tv_sec;
ut.ut_pid = cxt->pid;
if (cxt->hostname) {
- xstrncpy(ut.ut_host, cxt->hostname, sizeof(ut.ut_host));
+ str2memcpy(ut.ut_host, cxt->hostname, sizeof(ut.ut_host));
if (*cxt->hostaddress)
memcpy(&ut.ut_addr_v6, cxt->hostaddress,
sizeof(ut.ut_addr_v6));
ll.ll_time = t; /* ll_time is always 32bit */
if (cxt->tty_name)
- xstrncpy(ll.ll_line, cxt->tty_name, sizeof(ll.ll_line));
+ str2memcpy(ll.ll_line, cxt->tty_name, sizeof(ll.ll_line));
if (cxt->hostname)
- xstrncpy(ll.ll_host, cxt->hostname, sizeof(ll.ll_host));
+ str2memcpy(ll.ll_host, cxt->hostname, sizeof(ll.ll_host));
if (write_all(fd, (char *)&ll, sizeof(ll)))
warn(_("write lastlog failed"));
if (utp == NULL && cxt->tty_name) {
setutxent();
ut.ut_type = LOGIN_PROCESS;
- strncpy(ut.ut_line, cxt->tty_name, sizeof(ut.ut_line));
+ str2memcpy(ut.ut_line, cxt->tty_name, sizeof(ut.ut_line));
utp = getutxline(&ut);
}
if (utp == NULL && cxt->tty_number) {
setutxent();
ut.ut_type = DEAD_PROCESS;
- strncpy(ut.ut_id, cxt->tty_number, sizeof(ut.ut_id));
+ str2memcpy(ut.ut_id, cxt->tty_number, sizeof(ut.ut_id));
utp = getutxid(&ut);
}
memset(&ut, 0, sizeof(ut));
if (cxt->tty_number && ut.ut_id[0] == 0)
- strncpy(ut.ut_id, cxt->tty_number, sizeof(ut.ut_id));
+ str2memcpy(ut.ut_id, cxt->tty_number, sizeof(ut.ut_id));
if (cxt->username)
- strncpy(ut.ut_user, cxt->username, sizeof(ut.ut_user));
+ str2memcpy(ut.ut_user, cxt->username, sizeof(ut.ut_user));
if (cxt->tty_name)
- xstrncpy(ut.ut_line, cxt->tty_name, sizeof(ut.ut_line));
+ str2memcpy(ut.ut_line, cxt->tty_name, sizeof(ut.ut_line));
gettimeofday(&tv, NULL);
ut.ut_tv.tv_sec = tv.tv_sec;
ut.ut_type = USER_PROCESS;
ut.ut_pid = cxt->pid;
if (cxt->hostname) {
- xstrncpy(ut.ut_host, cxt->hostname, sizeof(ut.ut_host));
+ str2memcpy(ut.ut_host, cxt->hostname, sizeof(ut.ut_host));
if (*cxt->hostaddress)
memcpy(&ut.ut_addr_v6, cxt->hostaddress,
sizeof(ut.ut_addr_v6));