mirror of
https://github.com/shadow-maint/shadow.git
synced 2026-01-26 05:57:53 +00:00
lib/: Use simple assignment instead of memcpy(3)
memcpy(3) is overkill, and much more dangerous than simple assignment. Simple assignment adds type safety, and removes any possibility of buffer overflow due to accidentally specifying a wrong size. Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
parent
ceaca8460f
commit
e562faf109
@ -91,7 +91,7 @@ restart:
|
||||
* generate SIGTTOU, so do it *before* installing the signal handlers.
|
||||
*/
|
||||
if (input != STDIN_FILENO && tcgetattr(input, &oterm) == 0) {
|
||||
memcpy(&term, &oterm, sizeof(term));
|
||||
term = oterm;
|
||||
if (!(flags & RPP_ECHO_ON))
|
||||
term.c_lflag &= ~(ECHO | ECHONL);
|
||||
#ifdef VSTATUS
|
||||
|
||||
10
lib/utmp.c
10
lib/utmp.c
@ -318,16 +318,10 @@ prepare_utmp(const char *name, const char *line, const char *host,
|
||||
struct sockaddr_in *sa =
|
||||
(struct sockaddr_in *) info->ai_addr;
|
||||
# if defined(HAVE_STRUCT_UTMPX_UT_ADDR)
|
||||
memcpy (&(utent->ut_addr),
|
||||
&(sa->sin_addr),
|
||||
MIN(sizeof(utent->ut_addr),
|
||||
sizeof(sa->sin_addr)));
|
||||
utent->ut_addr = sa->sin_addr.s_addr;
|
||||
# endif
|
||||
# if defined(HAVE_STRUCT_UTMPX_UT_ADDR_V6)
|
||||
memcpy (utent->ut_addr_v6,
|
||||
&(sa->sin_addr),
|
||||
MIN(sizeof(utent->ut_addr_v6),
|
||||
sizeof(sa->sin_addr)));
|
||||
utent->ut_addr_v6[0] = sa->sin_addr.s_addr;
|
||||
} else if (info->ai_family == AF_INET6) {
|
||||
struct sockaddr_in6 *sa =
|
||||
(struct sockaddr_in6 *) info->ai_addr;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user