diff options
author | jfrijters <jfrijters> | 2012-08-30 12:57:29 +0400 |
---|---|---|
committer | jfrijters <jfrijters> | 2012-08-30 12:57:29 +0400 |
commit | 168129b3d0a729b65f9e2bbb3b2a867984b20ba2 (patch) | |
tree | 83ca8613422868bb62c6f255423501ed330e67f3 /openjdk/java | |
parent | b8df431272f63eaa06c0a9ccf911ff8f520dbeb9 (diff) |
Merged in security manager check to Font.createFont(int, File) from OpenJDK.
Diffstat (limited to 'openjdk/java')
-rw-r--r-- | openjdk/java/awt/Font.java | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/openjdk/java/awt/Font.java b/openjdk/java/awt/Font.java index 1c60806d..7c24f365 100644 --- a/openjdk/java/awt/Font.java +++ b/openjdk/java/awt/Font.java @@ -36,6 +36,7 @@ import java.awt.geom.Rectangle2D; import java.awt.peer.FontPeer; import java.io.*; import java.lang.ref.SoftReference; +import java.nio.file.Files; import java.security.AccessController; import java.security.PrivilegedExceptionAction; import java.text.AttributedCharacterIterator.Attribute; @@ -924,10 +925,21 @@ public class Font implements java.io.Serializable public static Font createFont(int fontFormat, File fontFile) throws java.awt.FontFormatException, java.io.IOException { + fontFile = new File(fontFile.getPath()); + if (fontFormat != Font.TRUETYPE_FONT && fontFormat != Font.TYPE1_FONT) { throw new IllegalArgumentException ("font format not recognized"); } + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + FilePermission filePermission = + new FilePermission(fontFile.getPath(), "read"); + sm.checkPermission(filePermission); + } + if (!fontFile.canRead()) { + throw new IOException("Can't read " + fontFile); + } // create a private Font Collection and add the font data PrivateFontCollection pfc = new PrivateFontCollection(); try { |