Harden the security manager and make it less spammy. Clean up a bunch of deprecation warnings from guava.

This commit is contained in:
Christian 2014-06-21 23:03:41 -04:00
parent 94f6fffc80
commit 6aae913919
3 changed files with 13 additions and 13 deletions

View File

@ -16,7 +16,6 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@ -43,8 +42,7 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.google.common.io.CharStreams;
import com.google.common.io.InputSupplier;
import com.google.common.io.CharSource;
import cpw.mods.fml.common.patcher.ClassPatchManager;
import cpw.mods.fml.relauncher.FMLRelaunchLog;
@ -78,8 +76,8 @@ public class FMLDeobfuscatingRemapper extends Remapper {
{
File mapData = new File(deobfFileName);
LZMAInputSupplier zis = new LZMAInputSupplier(new FileInputStream(mapData));
InputSupplier<InputStreamReader> srgSupplier = CharStreams.newReaderSupplier(zis,Charsets.UTF_8);
List<String> srgList = CharStreams.readLines(srgSupplier);
CharSource srgSource = zis.asCharSource(Charsets.UTF_8);
List<String> srgList = srgSource.readLines();
rawMethodMaps = Maps.newHashMap();
rawFieldMaps = Maps.newHashMap();
Builder<String, String> builder = ImmutableBiMap.<String,String>builder();
@ -118,8 +116,8 @@ public class FMLDeobfuscatingRemapper extends Remapper {
{
InputStream classData = getClass().getResourceAsStream(deobfFileName);
LZMAInputSupplier zis = new LZMAInputSupplier(classData);
InputSupplier<InputStreamReader> srgSupplier = CharStreams.newReaderSupplier(zis,Charsets.UTF_8);
List<String> srgList = CharStreams.readLines(srgSupplier);
CharSource srgSource = zis.asCharSource(Charsets.UTF_8);
List<String> srgList = srgSource.readLines();
rawMethodMaps = Maps.newHashMap();
rawFieldMaps = Maps.newHashMap();
Builder<String, String> builder = ImmutableBiMap.<String,String>builder();

View File

@ -17,9 +17,9 @@ import java.io.InputStream;
import LZMA.LzmaInputStream;
import com.google.common.io.InputSupplier;
import com.google.common.io.ByteSource;
public class LZMAInputSupplier implements InputSupplier<InputStream> {
public class LZMAInputSupplier extends ByteSource {
private InputStream compressedData;
public LZMAInputSupplier(InputStream compressedData)
@ -28,7 +28,7 @@ public class LZMAInputSupplier implements InputSupplier<InputStream> {
}
@Override
public InputStream getInput() throws IOException
public InputStream openStream() throws IOException
{
return new LzmaInputStream(this.compressedData);
}

View File

@ -16,9 +16,11 @@ public class FMLSecurityManager extends SecurityManager {
String permName = perm.getName() != null ? perm.getName() : "missing";
if (permName.startsWith("exitVM"))
{
String callingClass = getClassContext()[4].getName();
// FML is allowed to call system exit
if (!callingClass.startsWith("cpw.mods.fml."))
Class<?>[] classContexts = getClassContext();
String callingClass = classContexts.length > 3 ? classContexts[4].getName() : "none";
String callingParent = classContexts.length > 4 ? classContexts[5].getName() : "none";
// FML is allowed to call system exit and the Minecraft applet (from the quit button)
if (!(callingClass.startsWith("cpw.mods.fml.") || ( "net.minecraft.client.Minecraft".equals(callingClass) && "net.minecraft.client.Minecraft".equals(callingParent))))
{
throw new ExitTrappedException();
}