From: bluhm Date: Sun, 9 Jul 2023 09:33:30 +0000 (+0000) Subject: Allocate enough memory to pervent SIGSEGV or SIGABRT due to write X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=63cd6ed3906b495e90f1710ea58c012bc61429dc;p=openbsd Allocate enough memory to pervent SIGSEGV or SIGABRT due to write after free. There was confusion between size of struct and size of pointer. --- diff --git a/regress/sys/kern/unixsockets/unsendrecvthr.c b/regress/sys/kern/unixsockets/unsendrecvthr.c index 9a4f3628755..e224937129a 100644 --- a/regress/sys/kern/unixsockets/unsendrecvthr.c +++ b/regress/sys/kern/unixsockets/unsendrecvthr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: unsendrecvthr.c,v 1.1 2021/12/09 23:37:18 mvs Exp $ */ +/* $OpenBSD: unsendrecvthr.c,v 1.2 2023/07/09 09:33:30 bluhm Exp $ */ /* * Copyright (c) 2021 Vitaliy Makkoveev @@ -180,7 +180,7 @@ main(int argc, char *argv[]) err(1, "socketpair"); for (i = 0; i < 2; ++i) { - if (!(rx_data[i] = calloc(ncpu, sizeof(*rx_data)))) + if (!(rx_data[i] = calloc(ncpu, sizeof(struct rx_data)))) err(1, "calloc"); for (j = 0; j < ncpu; ++j) @@ -194,7 +194,7 @@ main(int argc, char *argv[]) } for (i = 0; i < 2; ++i) { - if (!(tx_args[i] = calloc(ncpu, sizeof(*tx_args)))) + if (!(tx_args[i] = calloc(ncpu, sizeof(struct thr_tx_arg)))) err(1, "calloc"); for (j = 0; j < ncpu; ++j) {