Source-Changes-HG archive

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

[src/trunk]: src/tests/lib/libc/sys PR/54062: Using random garbage in the mms...



details:   https://anonhg.NetBSD.org/src/rev/ec62a25130dc
branches:  trunk
changeset: 449685:ec62a25130dc
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Mar 16 21:46:43 2019 +0000

description:
PR/54062: Using random garbage in the mmsghdr (in this case 0xa5's from
jemalloc debug) makes the syscall unhappy. Zero out the memory instead...

diffstat:

 tests/lib/libc/sys/t_sendmmsg.c |  10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diffs (38 lines):

diff -r 9f3392bb530e -r ec62a25130dc tests/lib/libc/sys/t_sendmmsg.c
--- a/tests/lib/libc/sys/t_sendmmsg.c   Sat Mar 16 21:32:04 2019 +0000
+++ b/tests/lib/libc/sys/t_sendmmsg.c   Sat Mar 16 21:46:43 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: t_sendmmsg.c,v 1.2 2018/10/16 09:23:29 roy Exp $       */
+/*     $NetBSD: t_sendmmsg.c,v 1.3 2019/03/16 21:46:43 christos Exp $  */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: t_sendmmsg.c,v 1.2 2018/10/16 09:23:29 roy Exp $");
+__RCSID("$NetBSD: t_sendmmsg.c,v 1.3 2019/03/16 21:46:43 christos Exp $");
 
 #include <atf-c.h>
 #include <sys/types.h>
@@ -101,7 +101,7 @@
 //     setsock(fd[0], SO_RCVBUF);
 
        mmsgcnt = BUFSIZE / sizeof(DGRAM);
-       mmsghdr = malloc(sizeof(*mmsghdr) * mmsgcnt);
+       mmsghdr = calloc(mmsgcnt, sizeof(*mmsghdr));
        ATF_REQUIRE_MSG(mmsghdr != NULL, "malloc failed (%s)", strerror(errno));
        iov = malloc(sizeof(*iov) * mmsgcnt);
        ATF_REQUIRE_MSG(iov != NULL, "malloc failed (%s)", strerror(errno));
@@ -162,8 +162,8 @@
                                sched_yield();
                                continue;
                        }
-                       ATF_REQUIRE_MSG(cnt != -1, "sendmmsg failed (%s)",
-                           strerror(errno));
+                       ATF_REQUIRE_MSG(cnt != -1, "sendmmsg %u failed (%s)",
+                           n, strerror(errno));
                        if (debug)
                                printf("sendmmsg: sent %u messages\n", cnt);
                        n += cnt;



Home | Main Index | Thread Index | Old Index