From 56267d362d5769c8df07bf26d5e322610e0d24b4 Mon Sep 17 00:00:00 2001 From: Sascha Wildner Date: Wed, 24 Jan 2018 19:00:19 +0100 Subject: [PATCH] Fix two more gcc80 -Wsizeof-pointer-memaccess warnings. --- contrib/opie/libopie/insecure.c | 3 +-- libexec/comsat/comsat.c | 4 +--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/contrib/opie/libopie/insecure.c b/contrib/opie/libopie/insecure.c index 12c09ace97..f76661bd6e 100644 --- a/contrib/opie/libopie/insecure.c +++ b/contrib/opie/libopie/insecure.c @@ -135,8 +135,7 @@ int opieinsecure FUNCTION_NOARGS char host[sizeof(utmp.ut_host) + 1]; insecure = 1; - strncpy(host, utmp.ut_host, sizeof(utmp.ut_host)); - host[sizeof(utmp.ut_host)] = 0; + strncpy(host, utmp.ut_host, sizeof(host)); if ((s = strchr(host, ':')) != NULL) { int n = s - host; diff --git a/libexec/comsat/comsat.c b/libexec/comsat/comsat.c index 0d05e3ea0a..706135cbc0 100644 --- a/libexec/comsat/comsat.c +++ b/libexec/comsat/comsat.c @@ -28,7 +28,6 @@ * * @(#)comsat.c 8.1 (Berkeley) 6/4/93 * $FreeBSD: src/libexec/comsat/comsat.c,v 1.17 2005/02/14 17:42:56 stefanf Exp $ - * $DragonFly: src/libexec/comsat/comsat.c,v 1.6 2005/05/03 17:39:03 liamfoy Exp $ */ #include @@ -213,8 +212,7 @@ notify(struct utmp *utp, char *file, off_t offset, int folder) } tcgetattr(fileno(tp), &tio); cr = ((tio.c_oflag & (OPOST|ONLCR)) == (OPOST|ONLCR)) ? "\n" : "\n\r"; - strncpy(name, utp->ut_name, sizeof(utp->ut_name)); - name[sizeof(name) - 1] = '\0'; + strncpy(name, utp->ut_name, sizeof(name)); switch (stb.st_mode & (S_IXUSR | S_IXGRP)) { case S_IXUSR: case (S_IXUSR | S_IXGRP): -- 2.11.4.GIT