Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/include/sys use memcpy() for non C-strings.



details:   https://anonhg.NetBSD.org/src/rev/d2e5823d917e
branches:  trunk
changeset: 845561:d2e5823d917e
user:      mrg <mrg%NetBSD.org@localhost>
date:      Sun Oct 06 01:05:36 2019 +0000

description:
use memcpy() for non C-strings.

diffstat:

 tests/include/sys/t_socket.c |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diffs (27 lines):

diff -r 92aa339e6869 -r d2e5823d917e tests/include/sys/t_socket.c
--- a/tests/include/sys/t_socket.c      Sun Oct 06 01:04:49 2019 +0000
+++ b/tests/include/sys/t_socket.c      Sun Oct 06 01:05:36 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: t_socket.c,v 1.5 2017/01/13 21:30:41 christos Exp $    */
+/*     $NetBSD: t_socket.c,v 1.6 2019/10/06 01:05:36 mrg Exp $ */
 
 #include <sys/types.h>
 #include <sys/mount.h>
@@ -98,7 +98,7 @@
        memset(&sun, 0, sizeof(sun));
        sun.sun_family = AF_LOCAL;
 #define SOCKPATH "/com"
-       strncpy(sun.sun_path, SOCKPATH, sizeof(SOCKPATH));
+       memcpy(sun.sun_path, SOCKPATH, sizeof(SOCKPATH) - 1);
        s1 = rump_sys_socket(AF_LOCAL, SOCK_STREAM, 0);
        if (s1 == -1)
                atf_tc_fail_errno("socket 1");
@@ -114,7 +114,7 @@
        /* connect to unix domain socket */
        memset(&sun, 0, sizeof(sun));
        sun.sun_family = AF_LOCAL;
-       strncpy(sun.sun_path, SOCKPATH, sizeof(SOCKPATH));
+       memcpy(sun.sun_path, SOCKPATH, sizeof(SOCKPATH) - 1);
        s2 = rump_sys_socket(AF_LOCAL, SOCK_STREAM, 0);
        if (s2 == -1)
                atf_tc_fail_errno("socket 2");



Home | Main Index | Thread Index | Old Index