summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormpi <mpi@openbsd.org>2018-12-05 15:42:45 +0000
committermpi <mpi@openbsd.org>2018-12-05 15:42:45 +0000
commita3ba8ef920d483af975a4ff1684e43b6665ff9b7 (patch)
treec0a6056ac17719ffa032fa5cc2532fadb9038acd
parentfix incorrect usage of the .Bx macro; (diff)
downloadwireguard-openbsd-a3ba8ef920d483af975a4ff1684e43b6665ff9b7.tar.xz
wireguard-openbsd-a3ba8ef920d483af975a4ff1684e43b6665ff9b7.zip
free(9) size for temporary buffer.
ok ratchov@
-rw-r--r--sys/kern/sysv_msg.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/sys/kern/sysv_msg.c b/sys/kern/sysv_msg.c
index 329afef73b7..7f745a91356 100644
--- a/sys/kern/sysv_msg.c
+++ b/sys/kern/sysv_msg.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sysv_msg.c,v 1.33 2016/09/15 02:00:16 dlg Exp $ */
+/* $OpenBSD: sysv_msg.c,v 1.34 2018/12/05 15:42:45 mpi Exp $ */
/* $NetBSD: sysv_msg.c,v 1.19 1996/02/09 19:00:18 christos Exp $ */
/*
* Copyright (c) 2009 Bret S. Lambert <blambert@openbsd.org>
@@ -658,7 +658,7 @@ sysctl_sysvmsg(int *name, u_int namelen, void *where, size_t *sizep)
{
struct msg_sysctl_info *info;
struct que *que;
- size_t infolen;
+ size_t infolen, infolen0;
int error;
switch (*name) {
@@ -675,10 +675,10 @@ sysctl_sysvmsg(int *name, u_int namelen, void *where, size_t *sizep)
* message queues; for now, emulate this behavior
* until a more thorough fix can be made.
*/
- infolen = sizeof(msginfo) +
+ infolen0 = sizeof(msginfo) +
msginfo.msgmni * sizeof(struct msqid_ds);
if (where == NULL) {
- *sizep = infolen;
+ *sizep = infolen0;
return (0);
}
@@ -692,14 +692,14 @@ sysctl_sysvmsg(int *name, u_int namelen, void *where, size_t *sizep)
if (*sizep == sizeof(struct msginfo))
return (copyout(&msginfo, where, sizeof(msginfo)));
- info = malloc(infolen, M_TEMP, M_WAIT|M_ZERO);
+ info = malloc(infolen0, M_TEMP, M_WAIT|M_ZERO);
/* if the malloc slept, this may have changed */
infolen = sizeof(msginfo) +
msginfo.msgmni * sizeof(struct msqid_ds);
if (*sizep < infolen) {
- free(info, M_TEMP, 0);
+ free(info, M_TEMP, infolen0);
return (ENOMEM);
}
@@ -716,7 +716,7 @@ sysctl_sysvmsg(int *name, u_int namelen, void *where, size_t *sizep)
error = copyout(info, where, infolen);
- free(info, M_TEMP, 0);
+ free(info, M_TEMP, infolen0);
return (error);