From 41f27456aca79bb327a6312a801d6804b9e4197f Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Fri, 24 May 1996 21:42:06 +0000 Subject: Fri May 24 17:30:50 1996 Roland McGrath * login/pututline_r.c: Use struct assignment instead of memcpy. * login/getutline_r.c: Use strncmp instead of comparing two pointers that will only be equal if you are overwriting the data and screwing yourself anyway. --- login/getutline_r.c | 3 ++- login/pututline_r.c | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'login') diff --git a/login/getutline_r.c b/login/getutline_r.c index 62c8c2f..84c77cb 100644 --- a/login/getutline_r.c +++ b/login/getutline_r.c @@ -53,7 +53,8 @@ getutline_r (const struct utmp *line, struct utmp **utmp, /* Update position pointer. */ utmp_data->loc_utmp += sizeof (struct utmp); } - while (line->ut_line != utmp_data->ubuf.ut_line); + while (strncmp (line->ut_line, utmp_data->ubuf.ut_line, + sizeof line->ut_line)); *utmp = &utmp_data->ubuf; diff --git a/login/pututline_r.c b/login/pututline_r.c index 365a376..92ba8fb 100644 --- a/login/pututline_r.c +++ b/login/pututline_r.c @@ -44,9 +44,9 @@ pututline_r (const struct utmp *utmp_ptr, struct utmp_data *utmp_data) struct utmp_data *data_tmp = alloca (sizeof (utmp_data)); struct utmp *dummy; - memcpy (data_tmp, utmp_data, sizeof (utmp_data)); + *data_tmp = *utmp_data; utmp_data = data_tmp; - + if (getutid_r (utmp_ptr, &dummy, utmp_data) < 0) { if (errno != ESRCH) @@ -66,7 +66,7 @@ pututline_r (const struct utmp *utmp_ptr, struct utmp_data *utmp_data) /* XXX An alternative solution would be to call an SUID root program which write the new value. */ - + /* Try to lock the file. */ if (flock (utmp_data->ut_fd, LOCK_EX | LOCK_NB) < 0 && errno != ENOSYS) { @@ -76,7 +76,7 @@ pututline_r (const struct utmp *utmp_ptr, struct utmp_data *utmp_data) /* This time we ignore the error. */ (void) flock (utmp_data->ut_fd, LOCK_EX | LOCK_NB); } - + /* Write the new data. */ if (write (utmp_data->ut_fd, &utmp_data->ubuf, sizeof (struct utmp)) != sizeof (struct utmp)) -- cgit v1.1