git: c43e12a46f32 - main - emulators/virtualbox-ose-additions-legacy: Import improvements from non legacy port

From: Guido Falsi <madpilot_at_FreeBSD.org>
Date: Sun, 17 Oct 2021 09:32:42 UTC
The branch main has been updated by madpilot:

URL: https://cgit.FreeBSD.org/ports/commit/?id=c43e12a46f329c2ff336f06c61a6eb6be0ac9108

commit c43e12a46f329c2ff336f06c61a6eb6be0ac9108
Author:     Guido Falsi <madpilot@FreeBSD.org>
AuthorDate: 2021-10-17 09:29:56 +0000
Commit:     Guido Falsi <madpilot@FreeBSD.org>
CommitDate: 2021-10-17 09:32:33 +0000

    emulators/virtualbox-ose-additions-legacy: Import improvements from non legacy port
    
    Import changes from commit 1b2394551c0385 to legacy port:
    
    In the virtualbox virtual filesystem code we ship as a patch some
    code in an else block is commented out. This produces a code path
    in which a pointer variable is dereferenced in an unassigned state,
    causing random crashes.
    
    Lacking a better fix, give a default value of NULL to the pointer,
    which at least avoids the random pointer dereference issue.
    
    PR:             255386
    
    Alsso import fix for building on recent head from cec55f41e10f13:
    
    Fix build after head commit b4a58fbf640409a1 (vfs: remove cn_thread)
    
    MFH:            2021Q4
---
 emulators/virtualbox-ose-legacy/Makefile           |  2 +-
 ...VBox_Additions_freebsd_vboxvfs_vboxvfs__vnops.c | 25 +++++++++-------------
 2 files changed, 11 insertions(+), 16 deletions(-)

diff --git a/emulators/virtualbox-ose-legacy/Makefile b/emulators/virtualbox-ose-legacy/Makefile
index e51925fdddf8..fa4c0a7f749f 100644
--- a/emulators/virtualbox-ose-legacy/Makefile
+++ b/emulators/virtualbox-ose-legacy/Makefile
@@ -2,7 +2,7 @@
 
 PORTNAME=	virtualbox-ose
 PORTVERSION=	5.2.44
-PORTREVISION=	8
+PORTREVISION=	9
 CATEGORIES=	emulators
 MASTER_SITES=	https://download.oracle.com/virtualbox/${PORTVERSION}/
 PKGNAMESUFFIX?=	-legacy
diff --git a/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_freebsd_vboxvfs_vboxvfs__vnops.c b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_freebsd_vboxvfs_vboxvfs__vnops.c
index bc42812105e4..068f98f21d1c 100644
--- a/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_freebsd_vboxvfs_vboxvfs__vnops.c
+++ b/emulators/virtualbox-ose-legacy/files/patch-src_VBox_Additions_freebsd_vboxvfs_vboxvfs__vnops.c
@@ -1,18 +1,6 @@
---- src/VBox/Additions/freebsd/vboxvfs/vboxvfs_vnops.c.orig	2020-07-09 16:50:11 UTC
+--- src/VBox/Additions/freebsd/vboxvfs/vboxvfs_vnops.c.orig	2021-07-28 16:16:27 UTC
 +++ src/VBox/Additions/freebsd/vboxvfs/vboxvfs_vnops.c
-@@ -1,10 +1,6 @@
--/* $Id: vboxvfs_vnops.c $ */
--/** @file
-- * Description.
-- */
--
- /*
-  * Copyright (C) 2008-2017 Oracle Corporation
-+ * Copyright (C) 2017 Mahdi Mokhtari
-  *
-  * This file is part of VirtualBox Open Source Edition (OSE), as
-  * available from http://www.virtualbox.org. This file is free software;
-@@ -14,228 +10,1347 @@
+@@ -14,228 +14,1354 @@
   * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
   * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
   */
@@ -172,6 +160,9 @@
 +	.vop_write	= vboxfs_write,
 +	.vop_bmap	= VOP_EOPNOTSUPP
  };
++#if __FreeBSD_version > 1300068
++VFS_VOP_VECTOR_REGISTER(vboxfs_vnodeops);
++#endif
  
 -static int vboxvfs_access(struct vop_access_args *ap)
 +static uint64_t
@@ -1128,7 +1119,7 @@
 +	struct vnode *vp = ap->a_vp;
 +	struct uio *uio = ap->a_uio;
 +	struct vboxfs_node *dir = VP_TO_VBOXFS_NODE(vp);
-+	struct vboxfs_node *node;
++	struct vboxfs_node *node = NULL;
 +	struct sffs_dirent *dirent = NULL;
 +	sffs_dirents_t *cur_buf;
 +	off_t offset = 0;
@@ -1406,7 +1397,11 @@
 +			    cnp->cn_flags & DOWHITEOUT &&
 +			    cnp->cn_flags & ISWHITEOUT))) {
 +				error = VOP_ACCESS(dvp, VWRITE, cnp->cn_cred,
++#if __FreeBSD_version < 1400037
 +				    cnp->cn_thread);
++#else
++				    curthread);
++#endif
 +				if (error != 0)
 +					goto out;
 +