]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Revert previous commit.
authorOliver Kurth <okurth@vmware.com>
Fri, 15 Sep 2017 18:23:45 +0000 (11:23 -0700)
committerOliver Kurth <okurth@vmware.com>
Fri, 15 Sep 2017 18:23:45 +0000 (11:23 -0700)
open-vm-tools/lib/misc/strutil.c

index b5c616a6a15e96d744f1062b94da8da5ea2e7a1a..52d2f5320b92096159c1abf60a514a89a91a5358 100644 (file)
@@ -26,7 +26,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <stdint.h>
 #if !defined(_WIN32)
 #include <strings.h> /* For strncasecmp */
 #endif
@@ -1141,21 +1140,15 @@ StrUtil_SafeDynBufPrintf(DynBuf *b,        // IN/OUT
  */
 
 void
-StrUtil_SafeStrcat(char **prefix,    // IN/OUT:
-                   const char *str)  // IN:
+StrUtil_SafeStrcat(char **prefix,    // IN/OUT
+                   const char *str)  // IN
 {
    char *tmp;
-   size_t plen = (*prefix == NULL) ? 0 : strlen(*prefix);
+   size_t plen = *prefix != NULL ? strlen(*prefix) : 0;
    size_t slen = strlen(str);
 
-   /*
-    * If we're manipulating strings that are anywhere near max(size_t)/2 in
-    * length we're doing something very wrong. Avoid potential overflow by
-    * checking for "insane" operations. Prevent the problem before it gets
-    * started.
-    */
-
-   VERIFY((plen < (SIZE_MAX/2)) && (slen < (SIZE_MAX/2)));
+   /* Check for overflow */
+   VERIFY((size_t)-1 - plen > slen + 1);
 
    tmp = Util_SafeRealloc(*prefix, plen + slen + 1 /* NUL */);