Module Name:    src
Committed By:   maxv
Date:           Sat Aug 24 14:08:35 UTC 2019

Modified Files:
        src/sys/compat/linux/common: linux_socket.c

Log Message:
Hum, don't pass an mbuf to realloc(). Inspired from copyin32_msg_control().


To generate a diff of this commit:
cvs rdiff -u -r1.146 -r1.147 src/sys/compat/linux/common/linux_socket.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/compat/linux/common/linux_socket.c
diff -u src/sys/compat/linux/common/linux_socket.c:1.146 src/sys/compat/linux/common/linux_socket.c:1.147
--- src/sys/compat/linux/common/linux_socket.c:1.146	Sat Aug 24 12:33:25 2019
+++ src/sys/compat/linux/common/linux_socket.c	Sat Aug 24 14:08:35 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_socket.c,v 1.146 2019/08/24 12:33:25 maxv Exp $	*/
+/*	$NetBSD: linux_socket.c,v 1.147 2019/08/24 14:08:35 maxv Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.146 2019/08/24 12:33:25 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.147 2019/08/24 14:08:35 maxv Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -568,14 +568,15 @@ linux_sys_sendmsg(struct lwp *l, const s
 			/* Check the buffer is big enough */
 			if (__predict_false(cidx + cspace > clen)) {
 				u_int8_t *nc;
+				size_t nclen;
 
-				clen = cidx + cspace;
-				if (clen >= PAGE_SIZE) {
+				nclen = cidx + cspace;
+				if (nclen >= PAGE_SIZE) {
 					error = EINVAL;
 					goto done;
 				}
 				nc = realloc(clen <= MLEN ? NULL : control,
-						clen, M_TEMP, M_WAITOK);
+						nclen, M_TEMP, M_WAITOK);
 				if (!nc) {
 					error = ENOMEM;
 					goto done;
@@ -584,6 +585,7 @@ linux_sys_sendmsg(struct lwp *l, const s
 					/* Old buffer was in mbuf... */
 					memcpy(nc, control, cidx);
 				control = nc;
+				clen = nclen;
 			}
 
 			/* Copy header */

Reply via email to