RFR: 8337408: Use GetTempPath2 API instead of GetTempPath

Dhamoder Nalla dhanalla at openjdk.org
Thu Aug 15 17:03:17 UTC 2024


Use the GetTempPath2 APIs instead of the GetTempPath APIs in native code across the OpenJDK repository to retrieve the temporary directory path, as GetTempPath2 provides enhanced security. While GetTempPath may still function without errors, using GetTempPath2 reduces the risk of potential exploits for users.


The code to dynamically load GetTempPath2 is duplicated due to the following reasons.  I would appreciate any suggestions to remove the duplication where possible:

1. The changes span across four different folders—java.base, jdk.package, jdk.attach, and hotspot—with no shared code between them.
2. Some parts of the code use version A, while others use version W (ANSI vs. Unicode).
3. Some parts of the code are written in C others in C++.

-------------

Commit messages:
 - fix spaces
 - Use GetTempPath2 API instead of GetTempPath

Changes: https://git.openjdk.org/jdk/pull/20600/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=20600&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8337408
  Stats: 78 lines in 4 files changed: 70 ins; 0 del; 8 mod
  Patch: https://git.openjdk.org/jdk/pull/20600.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/20600/head:pull/20600

PR: https://git.openjdk.org/jdk/pull/20600


More information about the core-libs-dev mailing list