From 3a8515045c906b0174fb74f25b425f532b9cf2d1 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 14 Sep 2014 07:54:29 +0200 Subject: Bug 1067 - IOUtil.testDirExec(File) needs to preserve SPACE in exetst.getCanonicalPath() command Having a test-executable file with SPACE in it's temporary path, e.g. Unix: /magic temp/user/ Windows XP: C:\Documents and Settings\user\temp results to split up commands if using 'Process.exec(String)', since it utilizes a StringTokenizer to assemble the command String[]. This patch uses 'Process.exec(String[])' avoiding splitting up SPACE in the full command string/path. Major impact is on 'Windows XP', where a SPACE separated TEMP/TMP folder is the default. Note-1: Commit 9bc3d3f78bb2fb1aa0ccfb02ffb5bdda74420cac introduced testing executable permission on Windows (Bug 1015) and rendered this issue visible. To reproduce the issue on Windows: +++ set TEMP=C:\Documents and Settings\jogamp\temp set TMP=C:\Documents and Settings\jogamp\temp "C:\Program Files (x86)\Mozilla Firefox\firefox.exe" +++ Note-2: This bug affects all platforms! --- src/java/com/jogamp/common/util/IOUtil.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/java/com/jogamp/common/util/IOUtil.java') diff --git a/src/java/com/jogamp/common/util/IOUtil.java b/src/java/com/jogamp/common/util/IOUtil.java index d9fb9cf..76420db 100644 --- a/src/java/com/jogamp/common/util/IOUtil.java +++ b/src/java/com/jogamp/common/util/IOUtil.java @@ -821,7 +821,9 @@ public class IOUtil { fout.write(shellCode); fout.close(); } - final Process pr = Runtime.getRuntime().exec(exetst.getCanonicalPath()); + // Using 'Process.exec(String[])' avoids StringTokenizer of 'Process.exec(String)' + // and hence splitting up command by spaces! + final Process pr = Runtime.getRuntime().exec(new String[] { exetst.getCanonicalPath() } ); /** * Disable StreamMonitor, which throttles exec-test performance a lot! * @@ -1086,7 +1088,8 @@ public class IOUtil { } final File r = executable ? tempRootExec : tempRootNoexec ; if(null == r) { - throw new RuntimeException("Could not determine a temporary directory"); + final String exe_s = executable ? "executable " : ""; + throw new RuntimeException("Could not determine a temporary "+exe_s+"directory"); } final FilePermission fp = new FilePermission(r.getAbsolutePath(), "read,write,delete"); SecurityUtil.checkPermission(fp); -- cgit v1.2.3