From 33205aafc87a147729ddbdfd562d08edcd0c5cd3 Mon Sep 17 00:00:00 2001 From: Oliver Kurth Date: Fri, 6 Jul 2018 15:02:36 -0700 Subject: [PATCH] Common source file changes not directly applicable to open-vm-tools. --- open-vm-tools/lib/include/util.h | 1 + .../lib/include/vm_product_versions.h | 2 +- open-vm-tools/lib/misc/utilMem.c | 33 +++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/open-vm-tools/lib/include/util.h b/open-vm-tools/lib/include/util.h index 3e2d44130..9281609c3 100644 --- a/open-vm-tools/lib/include/util.h +++ b/open-vm-tools/lib/include/util.h @@ -302,6 +302,7 @@ char *UtilSafeStrndup1(const char *s, size_t n, void *Util_Memdup(const void *src, size_t size); void *Util_Memcpy(void *dest, const void *src, size_t count); +void Util_Memfree(void *ptr); Bool Util_ConstTimeMemDiff(const void *secret, const void *guess, size_t len); Bool Util_ConstTimeStrDiff(const char *secret, const char *guess); diff --git a/open-vm-tools/lib/include/vm_product_versions.h b/open-vm-tools/lib/include/vm_product_versions.h index e5fb41fe7..87d20c285 100644 --- a/open-vm-tools/lib/include/vm_product_versions.h +++ b/open-vm-tools/lib/include/vm_product_versions.h @@ -392,7 +392,7 @@ * a parameter that no longer match the content of the dormant license * file. */ -#define PRODUCT_MAC_DESKTOP_VERSION_STRING_FOR_LICENSE "10.0" +#define PRODUCT_MAC_DESKTOP_VERSION_STRING_FOR_LICENSE "11.0" #define PRODUCT_PLAYER_VERSION_STRING_FOR_LICENSE "14.0" #define PRODUCT_VMRC_VERSION_STRING_FOR_LICENSE "10.0" #define PRODUCT_FLEX_VERSION_STRING_FOR_LICENSE "8.0" diff --git a/open-vm-tools/lib/misc/utilMem.c b/open-vm-tools/lib/misc/utilMem.c index 6a288a0d3..2ad5926d6 100644 --- a/open-vm-tools/lib/misc/utilMem.c +++ b/open-vm-tools/lib/misc/utilMem.c @@ -488,6 +488,39 @@ Util_Memcpy(void *dest, // OUT: } +/* + *----------------------------------------------------------------------------- + * + * Util_Memfree -- + * + * Frees the memory space pointed to by ptr. + * + * The reason why this function is externally visible (not static) + * is to avoid freeing memory across dll boundary. + * In vmwarebase, we have many API that return newly allocated memory + * to the caller. If the caller linked against a different msvc runtime + * (for example, vmrest linked against msvcrt.dll), we will crash. + * Using Util_Memfree() can avoid this kind of problem, since it sits + * inside vmwarebase too. It will call the right free(), the one that + * match the malloc() used in vmwarebase. + * + * Results: + * The memory space pointed to by ptr will be freed. + * If ptr is NULL, no operation is performed. + * + * Side effects: + * None. + * + *----------------------------------------------------------------------------- + */ + +void +Util_Memfree(void *ptr) // IN: +{ + free(ptr); +} + + /* *----------------------------------------------------------------------------- * -- 2.47.3