3
# Date 1288382134 -14400
4
# Node ID 5e70dbac6a7d3743e64e19399552a60d25ba5cff
5
# Parent f3dff5c1b9c2cc8d38fde74c3661786f6332a3eb
6
6985453: Font.createFont may expose some system properties in exception text
7
Reviewed-by: prr, hawtin
9
diff --git a/src/share/classes/sun/font/FileFont.java b/src/share/classes/sun/font/FileFont.java
10
--- openjdk/jdk/src/share/classes/sun/font/FileFont.java
11
+++ openjdk/jdk/src/share/classes/sun/font/FileFont.java
12
@@ -48,6 +48,9 @@ import java.util.HashSet;
13
import java.util.HashSet;
14
import java.util.HashMap;
16
+import java.security.AccessController;
17
+import java.security.PrivilegedActionException;
18
+import java.security.PrivilegedExceptionAction;
20
public abstract class FileFont extends PhysicalFont {
22
@@ -284,4 +287,49 @@ public abstract class FileFont extends P
27
+ protected String getPublicFileName() {
28
+ SecurityManager sm = System.getSecurityManager();
32
+ boolean canReadProperty = true;
35
+ sm.checkPropertyAccess("java.io.tmpdir");
36
+ } catch (SecurityException e) {
37
+ canReadProperty = false;
40
+ if (canReadProperty) {
44
+ final File f = new File(platName);
46
+ Boolean isTmpFile = Boolean.FALSE;
48
+ isTmpFile = AccessController.doPrivileged(
49
+ new PrivilegedExceptionAction<Boolean>() {
50
+ public Boolean run() {
51
+ File tmp = new File(System.getProperty("java.io.tmpdir"));
53
+ String tpath = tmp.getCanonicalPath();
54
+ String fpath = f.getCanonicalPath();
56
+ return (fpath == null) || fpath.startsWith(tpath);
57
+ } catch (IOException e) {
58
+ return Boolean.TRUE;
63
+ } catch (PrivilegedActionException e) {
64
+ // unable to verify whether value of java.io.tempdir will be
65
+ // exposed, so return only a name of the font file.
66
+ isTmpFile = Boolean.TRUE;
69
+ return isTmpFile ? "temp file" : platName;
72
diff --git a/src/share/classes/sun/font/TrueTypeFont.java b/src/share/classes/sun/font/TrueTypeFont.java
73
--- openjdk/jdk/src/share/classes/sun/font/TrueTypeFont.java
74
+++ openjdk/jdk/src/share/classes/sun/font/TrueTypeFont.java
75
@@ -504,7 +504,8 @@ public class TrueTypeFont extends FileFo
79
- throw new FontFormatException("Unsupported sfnt " + platName);
80
+ throw new FontFormatException("Unsupported sfnt " +
81
+ getPublicFileName());
84
/* Now have the offset of this TT font (possibly within a TTC)
85
@@ -1369,6 +1370,6 @@ public class TrueTypeFont extends FileFo
87
public String toString() {
88
return "** TrueType Font: Family="+familyName+ " Name="+fullName+
89
- " style="+style+" fileName="+platName;
90
+ " style="+style+" fileName="+getPublicFileName();
93
diff --git a/src/share/classes/sun/font/Type1Font.java b/src/share/classes/sun/font/Type1Font.java
94
--- openjdk/jdk/src/share/classes/sun/font/Type1Font.java
95
+++ openjdk/jdk/src/share/classes/sun/font/Type1Font.java
96
@@ -677,7 +677,7 @@ public class Type1Font extends FileFont
98
public String toString() {
99
return "** Type1 Font: Family="+familyName+ " Name="+fullName+
100
- " style="+style+" fileName="+platName;
101
+ " style="+style+" fileName="+getPublicFileName();