git: 03d66a4c640d - main - devel/electron13: fix obtaining HOST_NAME_MAX

From: Hiroki Tagato <tagattie_at_FreeBSD.org>
Date: Tue, 14 Dec 2021 13:20:51 UTC
The branch main has been updated by tagattie:

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

commit 03d66a4c640d3363f919b29d0298f6e132bfda48
Author:     Adam Wolk <a.wolk@fudosecurity.com>
AuthorDate: 2021-12-14 13:18:04 +0000
Commit:     Hiroki Tagato <tagattie@FreeBSD.org>
CommitDate: 2021-12-14 13:20:27 +0000

    devel/electron13: fix obtaining HOST_NAME_MAX
    
    Using sysconf(3) API lead to accidental introduction of variable
    length arrays (VLA) in the port. Additionally gethostname(3) has been
    passed _SC_HOST_NAME_MAX incorrectly as the HOST_NAME_MAX length.
    
    Fall back to using _POSIX_HOST_NAME_MAX as the remaining code is not
    ready for introducing sysconf(3) as a patch.
    
    Bump PORTREVISION to rebuild with the new patch.
    
    The patch was lifted from www/chromium which has a similar diff
    pending.
    
    Sponsored by:   Fudo Security
    Differential Revision:  https://reviews.freebsd.org/D30064
---
 devel/electron13/Makefile                                        | 2 +-
 ...onents_sync__device__info_local__device__info__util__linux.cc | 9 ++++-----
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/devel/electron13/Makefile b/devel/electron13/Makefile
index c8b7765fd90a..ab0af69b4f01 100644
--- a/devel/electron13/Makefile
+++ b/devel/electron13/Makefile
@@ -1,7 +1,7 @@
 PORTNAME=	electron
 DISTVERSIONPREFIX=	v
 DISTVERSION=	${ELECTRON_VER:S/-beta./.b/}
-PORTREVISION=	1
+PORTREVISION=	2
 CATEGORIES=	devel
 MASTER_SITES=	https://commondatastorage.googleapis.com/chromium-browser-official/:chromium \
 		https://commondatastorage.googleapis.com/chromium-fonts/:chromium_testfonts
diff --git a/devel/electron13/files/patch-components_sync__device__info_local__device__info__util__linux.cc b/devel/electron13/files/patch-components_sync__device__info_local__device__info__util__linux.cc
index 7ffeb716b5f4..d3186df824fc 100644
--- a/devel/electron13/files/patch-components_sync__device__info_local__device__info__util__linux.cc
+++ b/devel/electron13/files/patch-components_sync__device__info_local__device__info__util__linux.cc
@@ -1,14 +1,13 @@
---- components/sync_device_info/local_device_info_util_linux.cc.orig	2021-04-14 01:08:47 UTC
+--- components/sync_device_info/local_device_info_util_linux.cc.orig	2021-07-15 19:13:38 UTC
 +++ components/sync_device_info/local_device_info_util_linux.cc
-@@ -38,8 +38,9 @@ std::string GetPersonalizableDeviceNameInternal() {
+@@ -38,8 +38,8 @@ std::string GetPersonalizableDeviceNameInternal() {
  #if BUILDFLAG(IS_CHROMEOS_ASH)
    return GetChromeOSDeviceNameFromType();
  #else
 -  char hostname[HOST_NAME_MAX];
 -  if (gethostname(hostname, HOST_NAME_MAX) == 0)  // Success.
-+  int len = sysconf(_SC_HOST_NAME_MAX);
-+  char hostname[len];
-+  if (gethostname(hostname, _SC_HOST_NAME_MAX) == 0)  // Success.
++  char hostname[_POSIX_HOST_NAME_MAX];
++  if (gethostname(hostname, _POSIX_HOST_NAME_MAX) == 0)  // Success.
      return hostname;
    return base::GetLinuxDistro();
  #endif