From owner-svn-ports-all@freebsd.org Sat Mar 10 22:56:55 2018 Return-Path: Delivered-To: svn-ports-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 055C7F3C238; Sat, 10 Mar 2018 22:56:55 +0000 (UTC) (envelope-from jpaetzel@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A93DE87F8A; Sat, 10 Mar 2018 22:56:54 +0000 (UTC) (envelope-from jpaetzel@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A43E21426A; Sat, 10 Mar 2018 22:56:54 +0000 (UTC) (envelope-from jpaetzel@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w2AMush1018825; Sat, 10 Mar 2018 22:56:54 GMT (envelope-from jpaetzel@FreeBSD.org) Received: (from jpaetzel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w2AMuskF018821; Sat, 10 Mar 2018 22:56:54 GMT (envelope-from jpaetzel@FreeBSD.org) Message-Id: <201803102256.w2AMuskF018821@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jpaetzel set sender to jpaetzel@FreeBSD.org using -f From: Josh Paetzel Date: Sat, 10 Mar 2018 22:56:54 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r464095 - in head/emulators/open-vm-tools: . files X-SVN-Group: ports-head X-SVN-Commit-Author: jpaetzel X-SVN-Commit-Paths: in head/emulators/open-vm-tools: . files X-SVN-Commit-Revision: 464095 X-SVN-Commit-Repository: ports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the ports tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Mar 2018 22:56:55 -0000 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@gmail.com Reviewed by: John Wolfe 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 + #include + #include ++#include + #include // for access, crypt, etc. + #if !defined USE_PAM && !defined __APPLE__ + #include +@@ -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 - #include - #include -+#include +@@ -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 -@@ -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) {