8194734: Handle to jimage file inherited into child processes (win)
authoralanb
Mon, 16 Apr 2018 09:36:01 +0100
changeset 49703 d2bea17edd96
parent 49702 09c01737ad27
child 49704 bc1c7e41e285
child 56431 a30d41eadcf8
8194734: Handle to jimage file inherited into child processes (win) Reviewed-by: alanb Contributed-by: alexandr.miloslavskiy@gmail.com
src/java.base/windows/native/libjimage/osSupport_windows.cpp
--- a/src/java.base/windows/native/libjimage/osSupport_windows.cpp	Sat Apr 14 08:41:42 2018 +0100
+++ b/src/java.base/windows/native/libjimage/osSupport_windows.cpp	Mon Apr 16 09:36:01 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -38,7 +38,8 @@
  * Return the file descriptor.
  */
 jint osSupport::openReadOnly(const char *path) {
-    return ::open(path, 0, 0);
+    // jimage file descriptors must not be inherited by child processes
+    return ::open(path, O_BINARY | O_NOINHERIT, O_RDONLY);
 }
 
 /**