svn commit: r464095 - in head/emulators/open-vm-tools: . files
Josh Paetzel
jpaetzel at FreeBSD.org
Sat Mar 10 22:56:55 UTC 2018
Author: jpaetzel
Date: Sat Mar 10 22:56:54 2018
New Revision: 464095
URL: https://svnweb.freebsd.org/changeset/ports/464095
Log:
Fix bug that causes crashes when running commands from the host
PR: 226478
Submitted by: german.mb at gmail.com
Reviewed by: John Wolfe <jwolfe at vmware.com>
Added:
head/emulators/open-vm-tools/files/patch-lib_auth_authPosix.c (contents, props changed)
head/emulators/open-vm-tools/files/patch-lib_file_fileTempPosix.c (contents, props changed)
Modified:
head/emulators/open-vm-tools/Makefile
head/emulators/open-vm-tools/files/patch-services_plugins_vix_vixTools.c
Modified: head/emulators/open-vm-tools/Makefile
==============================================================================
--- head/emulators/open-vm-tools/Makefile Sat Mar 10 22:43:38 2018 (r464094)
+++ head/emulators/open-vm-tools/Makefile Sat Mar 10 22:56:54 2018 (r464095)
@@ -4,7 +4,7 @@
PORTNAME= open-vm-tools
PORTVERSION= ${RELEASE_VER}
DISTVERSIONPREFIX= stable-
-PORTREVISION= 3
+PORTREVISION= 4
PORTEPOCH= 2
CATEGORIES= emulators
Added: head/emulators/open-vm-tools/files/patch-lib_auth_authPosix.c
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/emulators/open-vm-tools/files/patch-lib_auth_authPosix.c Sat Mar 10 22:56:54 2018 (r464095)
@@ -0,0 +1,45 @@
+--- lib/auth/authPosix.c.orig 2017-12-15 21:11:49 UTC
++++ lib/auth/authPosix.c
+@@ -1,5 +1,5 @@
+ /*********************************************************
+- * Copyright (C) 2003-2017 VMware, Inc. All rights reserved.
++ * Copyright (C) 2003-2018 VMware, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+@@ -19,6 +19,7 @@
+ #include <stdlib.h>
+ #include <stdio.h>
+ #include <string.h>
++#include <errno.h>
+ #include <unistd.h> // for access, crypt, etc.
+ #if !defined USE_PAM && !defined __APPLE__
+ #include <shadow.h>
+@@ -262,8 +263,8 @@ static struct pam_conv PAM_conversation = {
+ static AuthTokenInternal *
+ AuthAllocateToken(void)
+ {
++ long bufSize;
+ AuthTokenInternal *ati;
+- size_t bufSize;
+
+ /*
+ * We need to get the maximum size buffer needed by getpwuid_r from
+@@ -271,9 +272,15 @@ AuthAllocateToken(void)
+ * by the Posix_Get*_r() wrappers.
+ */
+
+- bufSize = (size_t) sysconf(_SC_GETPW_R_SIZE_MAX) * 4;
++ errno = 0;
++ bufSize = sysconf(_SC_GETPW_R_SIZE_MAX);
++ if ((errno != 0) || (bufSize <= 0)) {
++ bufSize = 16 * 1024; // Unlimited; pick something reasonable
++ }
+
+- ati = Util_SafeMalloc(sizeof *ati + bufSize);
++ bufSize *= 4;
++
++ ati = Util_SafeMalloc(sizeof *ati + (size_t) bufSize);
+ ati->bufSize = bufSize;
+
+ return ati;
Added: head/emulators/open-vm-tools/files/patch-lib_file_fileTempPosix.c
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/emulators/open-vm-tools/files/patch-lib_file_fileTempPosix.c Sat Mar 10 22:56:54 2018 (r464095)
@@ -0,0 +1,21 @@
+--- lib/file/fileTempPosix.c.orig 2017-12-15 21:11:49 UTC
++++ lib/file/fileTempPosix.c
+@@ -203,12 +203,17 @@ FileGetUserName(uid_t uid) // IN:
+ #if defined(__APPLE__)
+ memPoolSize = _PASSWORD_LEN;
+ #else
++ errno = 0;
+ memPoolSize = sysconf(_SC_GETPW_R_SIZE_MAX);
+
+- if (memPoolSize <= 0) {
++ if ((errno != 0) || (memPoolSize == 0)) {
+ Warning("%s: sysconf(_SC_GETPW_R_SIZE_MAX) failed.\n", __FUNCTION__);
+
+ return NULL;
++ }
++
++ if (memPoolSize == -1) { // Unlimited; pick something reasonable
++ memPoolSize = 16 * 1024;
+ }
+ #endif
+
Modified: head/emulators/open-vm-tools/files/patch-services_plugins_vix_vixTools.c
==============================================================================
--- head/emulators/open-vm-tools/files/patch-services_plugins_vix_vixTools.c Sat Mar 10 22:43:38 2018 (r464094)
+++ head/emulators/open-vm-tools/files/patch-services_plugins_vix_vixTools.c Sat Mar 10 22:56:54 2018 (r464095)
@@ -1,29 +1,29 @@
---- services/plugins/vix/vixTools.c.orig 2017-12-15 21:11:49 UTC
+--- services/plugins/vix/vixTools.c.orig 2018-02-24 17:50:37 UTC
+++ services/plugins/vix/vixTools.c
-@@ -52,6 +52,7 @@
- #include <stdarg.h>
- #include <fcntl.h>
- #include <errno.h>
-+#include <limits.h>
+@@ -10135,7 +10135,7 @@ abort:
+ struct passwd pwd;
+ struct passwd *ppwd = &pwd;
+ char *buffer = NULL; // a pool of memory for Posix_Getpwnam_r() to use.
+- size_t bufferSize;
++ long bufferSize;
- #ifdef _WIN32
- #include <WTypes.h>
-@@ -7330,7 +7331,7 @@ VixToolsRunScript(VixCommandRequestHeader *requestMsg,
- goto abort;
- }
- }
-- for (var = 0; var <= 0xFFFFFFFF; var++) {
-+ for (var = 0; ; var++) {
- free(tempScriptFilePath);
- tempScriptFilePath = Str_SafeAsprintf(NULL,
- "%s"DIRSEPS"%s%d%s",
-@@ -7372,6 +7373,9 @@ VixToolsRunScript(VixCommandRequestHeader *requestMsg,
- * deletes it), we should not try 4+ billion times.
- */
- break;
-+ }
-+ if (var == INT_MAX) {
-+ break;
- }
- }
- if (fd < 0) {
+ /*
+ * For POSIX systems, look up the uid of 'username', and compare
+@@ -10148,9 +10148,15 @@ abort:
+ * Multiply by 4 to compensate for the conversion to UTF-8 by
+ * the Posix_Getpwnam_r() wrapper.
+ */
+- bufferSize = (size_t) sysconf(_SC_GETPW_R_SIZE_MAX) * 4;
++ errno = 0;
++ bufferSize = sysconf(_SC_GETPW_R_SIZE_MAX);
++ if ((errno != 0) || (bufferSize <= 0)) {
++ bufferSize = 16 * 1024; // Unlimited; pick something reasonable
++ }
+
+- buffer = Util_SafeMalloc(bufferSize);
++ bufferSize *= 4;
++
++ buffer = Util_SafeMalloc((size_t)bufferSize);
+
+ if (Posix_Getpwnam_r(username, &pwd, buffer, bufferSize, &ppwd) != 0 ||
+ NULL == ppwd) {
More information about the svn-ports-all
mailing list