]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Avoid potential pointer truncation in Util_Memcpy32
authorKruti Pendharkar <kp025370@broadcom.com>
Tue, 3 Jun 2025 06:30:24 +0000 (23:30 -0700)
committerKruti Pendharkar <kp025370@broadcom.com>
Tue, 3 Jun 2025 06:30:24 +0000 (23:30 -0700)
`Util_Memcpy32` casts pointers to `long` types, but `long` is
not necessarily large enough to store a pointer without
truncation. (For example, Windows typically uses LLP64 where
`long` is a 32-bit integer type on x64 systems.  Although
`Util_Memcpy32` does its interesting work only for GCC, some
parts of our build use GCC on Windows, and apparently that
GCC configuration also uses LLP64.)

Cast to `intptr_t` instead.

open-vm-tools/lib/include/util.h

index 1e862298999f6b0abe4bcdf12b353746ea7a0c4e..35ad6b0dc50cfb9eec8c4b919c49b09526880b65 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (c) 1998-2024 Broadcom. All Rights Reserved.
+ * Copyright (c) 1998-2025 Broadcom. All Rights Reserved.
  * The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -403,7 +403,7 @@ Util_Memcpy32(void *dst,
            "cld \n\t"
            "rep ; movsl"  "\n\t"
         : "=&c" (dummy0), "=&D" (dummy1), "=&S" (dummy2)
-        : "0" (nbytes / 4), "1" ((long) dst), "2" ((long) src)
+        : "0" (nbytes / 4), "1" ((intptr_t) dst), "2" ((intptr_t) src)
         : "memory", "cc"
       );
       return dst;