提交 562d9f38 编写于 作者: A asaha

Merge

......@@ -387,7 +387,7 @@ endif
##########################################################################################
all: $(BUILD_JDK) $(BUILD_SECURITY) $(BUILD_JOBJC) $(BUILD_JOBJC_HEADERS) $(COPY_EXTRA) \
all: $(BUILD_JDK) $(BUILD_SECURITY) $(COPY_EXTRA) \
$(JDK_OUTPUTDIR)/classes/META-INF/services/com.sun.tools.xjc.Plugin \
$(BUILD_ACCESSBRIDGE_32) $(BUILD_ACCESSBRIDGE_64) \
$(BUILD_ACCESSBRIDGE_LEGACY)
......
......@@ -55,7 +55,7 @@ public class CClipboard extends SunClipboard {
}
protected void setContentsNative(Transferable contents) {
FlavorTable flavorMap = getDefaultFlavorTable();
// Don't use delayed Clipboard rendering for the Transferable's data.
// If we did that, we would call Transferable.getTransferData on
// the Toolkit thread, which is a security hole.
......
......@@ -25,27 +25,33 @@
package com.sun.media.sound;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import javax.sound.midi.Receiver;
import javax.sound.midi.Sequencer;
import javax.sound.midi.Synthesizer;
import javax.sound.midi.Transmitter;
import javax.sound.midi.spi.MidiDeviceProvider;
import javax.sound.midi.spi.MidiFileReader;
import javax.sound.midi.spi.MidiFileWriter;
import javax.sound.midi.spi.SoundbankReader;
import javax.sound.sampled.Clip;
import javax.sound.sampled.Port;
import javax.sound.sampled.SourceDataLine;
import javax.sound.sampled.TargetDataLine;
import javax.sound.sampled.spi.AudioFileReader;
import javax.sound.sampled.spi.AudioFileWriter;
import javax.sound.sampled.spi.FormatConversionProvider;
import javax.sound.sampled.spi.MixerProvider;
/**
* JDK13Services uses the Service class in JDK 1.3
* to discover a list of service providers installed
* in the system.
*
* JDK13Services uses the Service class in JDK 1.3 to discover a list of service
* providers installed in the system.
* <p>
* This class is public because it is called from javax.sound.midi.MidiSystem
* and javax.sound.sampled.AudioSystem. The alternative would be to make
* JSSecurityManager public, which is considered worse.
......@@ -54,80 +60,55 @@ import javax.sound.sampled.TargetDataLine;
*/
public final class JDK13Services {
/** The default for the length of the period to hold the cache.
This value is given in milliseconds. It is equivalent to
1 minute.
*/
private static final long DEFAULT_CACHING_PERIOD = 60000;
/** Filename of the properties file for default provider properties.
This file is searched in the subdirectory "lib" of the JRE directory
(this behaviour is hardcoded).
*/
/**
* Filename of the properties file for default provider properties. This
* file is searched in the subdirectory "lib" of the JRE directory (this
* behaviour is hardcoded).
*/
private static final String PROPERTIES_FILENAME = "sound.properties";
/** Cache for the providers.
Class objects of the provider type (MixerProvider, MidiDeviceProvider
...) are used as keys. The values are instances of ProviderCache.
*/
private static final Map providersCacheMap = new HashMap();
/** The length of the period to hold the cache.
This value is given in milliseconds.
*/
private static long cachingPeriod = DEFAULT_CACHING_PERIOD;
/** Properties loaded from the properties file for default provider
properties.
*/
/**
* Properties loaded from the properties file for default provider
* properties.
*/
private static Properties properties;
/** Private, no-args constructor to ensure against instantiation.
/**
* Private, no-args constructor to ensure against instantiation.
*/
private JDK13Services() {
}
/** Set the period provider lists are cached.
This method is only intended for testing.
*/
public static void setCachingPeriod(int seconds) {
cachingPeriod = seconds * 1000L;
}
/** Obtains a List containing installed instances of the
providers for the requested service.
The List of providers is cached for the period of time given by
{@link #cachingPeriod cachingPeriod}. During this period, the same
List instance is returned for the same type of provider. After this
period, a new instance is constructed and returned. The returned
List is immutable.
@param serviceClass The type of providers requested. This should be one
of AudioFileReader.class, AudioFileWriter.class,
FormatConversionProvider.class, MixerProvider.class,
MidiDeviceProvider.class, MidiFileReader.class, MidiFileWriter.class or
SoundbankReader.class.
@return A List of providers of the requested type. This List is
immutable.
/**
* Obtains a List containing installed instances of the providers for the
* requested service. The returned List is immutable.
*
* @param serviceClass The type of providers requested. This should be one
* of AudioFileReader.class, AudioFileWriter.class,
* FormatConversionProvider.class, MixerProvider.class,
* MidiDeviceProvider.class, MidiFileReader.class,
* MidiFileWriter.class or SoundbankReader.class.
*
* @return A List of providers of the requested type. This List is
* immutable.
*/
public static synchronized List getProviders(Class serviceClass) {
ProviderCache cache = (ProviderCache) providersCacheMap.get(serviceClass);
if (cache == null) {
cache = new ProviderCache();
providersCacheMap.put(serviceClass, cache);
public static List<?> getProviders(final Class<?> serviceClass) {
final List<?> providers;
if (!MixerProvider.class.equals(serviceClass)
&& !FormatConversionProvider.class.equals(serviceClass)
&& !AudioFileReader.class.equals(serviceClass)
&& !AudioFileWriter.class.equals(serviceClass)
&& !MidiDeviceProvider.class.equals(serviceClass)
&& !SoundbankReader.class.equals(serviceClass)
&& !MidiFileWriter.class.equals(serviceClass)
&& !MidiFileReader.class.equals(serviceClass)) {
providers = new ArrayList<>(0);
} else {
providers = JSSecurityManager.getProviders(serviceClass);
}
if (cache.providers == null ||
System.currentTimeMillis() > cache.lastUpdate + cachingPeriod) {
cache.providers = Collections.unmodifiableList(JSSecurityManager.getProviders(serviceClass));
cache.lastUpdate = System.currentTimeMillis();
}
return cache.providers;
return Collections.unmodifiableList(providers);
}
/** Obtain the provider class name part of a default provider property.
@param typeClass The type of the default provider property. This
should be one of Receiver.class, Transmitter.class, Sequencer.class,
......@@ -219,14 +200,4 @@ public final class JDK13Services {
}
return properties;
}
// INNER CLASSES
private static class ProviderCache {
// System time of the last update in milliseconds.
public long lastUpdate;
// The providers.
public List providers;
}
}
......@@ -185,8 +185,8 @@ final class JSSecurityManager {
return thread;
}
static <T> List<T> getProviders(final Class<T> providerClass) {
List<T> p = new ArrayList<>();
static synchronized <T> List<T> getProviders(final Class<T> providerClass) {
List<T> p = new ArrayList<>(7);
// ServiceLoader creates "lazy" iterator instance, but it ensures that
// next/hasNext run with permissions that are restricted by whatever
// creates the ServiceLoader instance, so it requires to be called from
......
/*
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2013, 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
......@@ -37,6 +37,7 @@ import javax.sql.rowset.spi.*;
import javax.sql.rowset.serial.*;
import com.sun.rowset.internal.*;
import com.sun.rowset.providers.*;
import sun.reflect.misc.ReflectUtil;
/**
* The standard implementation of the <code>CachedRowSet</code> interface.
......@@ -2959,13 +2960,9 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
// create new instance of the class
SQLData obj = null;
try {
obj = (SQLData)c.newInstance();
} catch (java.lang.InstantiationException ex) {
throw new SQLException(MessageFormat.format(resBundle.handleGetObject("cachedrowsetimpl.unableins").toString(),
ex.getMessage()));
} catch (java.lang.IllegalAccessException ex) {
throw new SQLException(MessageFormat.format(resBundle.handleGetObject("cachedrowsetimpl.unableins").toString(),
ex.getMessage()));
obj = (SQLData) ReflectUtil.newInstance(c);
} catch(Exception ex) {
throw new SQLException("Unable to Instantiate: ", ex);
}
// get the attributes from the struct
Object attribs[] = s.getAttributes(map);
......@@ -5710,13 +5707,9 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
// create new instance of the class
SQLData obj = null;
try {
obj = (SQLData)c.newInstance();
} catch (java.lang.InstantiationException ex) {
throw new SQLException(MessageFormat.format(resBundle.handleGetObject("cachedrowsetimpl.unableins").toString(),
ex.getMessage()));
} catch (java.lang.IllegalAccessException ex) {
throw new SQLException(MessageFormat.format(resBundle.handleGetObject("cachedrowsetimpl.unableins").toString(),
ex.getMessage()));
obj = (SQLData) ReflectUtil.newInstance(c);
} catch(Exception ex) {
throw new SQLException("Unable to Instantiate: ", ex);
}
// get the attributes from the struct
Object attribs[] = s.getAttributes(map);
......
/*
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2013, 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
......@@ -29,6 +29,7 @@ import java.sql.*;
import javax.sql.*;
import java.util.*;
import java.io.*;
import sun.reflect.misc.ReflectUtil;
import com.sun.rowset.*;
import java.text.MessageFormat;
......@@ -572,13 +573,9 @@ public class CachedRowSetWriter implements TransactionalWriter, Serializable {
// create new instance of the class
SQLData obj = null;
try {
obj = (SQLData)c.newInstance();
} catch (java.lang.InstantiationException ex) {
throw new SQLException(MessageFormat.format(resBundle.handleGetObject("cachedrowsetimpl.unableins").toString(),
ex.getMessage()));
} catch (java.lang.IllegalAccessException ex) {
throw new SQLException(MessageFormat.format(resBundle.handleGetObject("cachedrowsetimpl.unableins").toString(),
ex.getMessage()));
obj = (SQLData)ReflectUtil.newInstance(c);
} catch (Exception ex) {
throw new SQLException("Unable to Instantiate: ", ex);
}
// get the attributes from the struct
Object attribs[] = s.getAttributes(map);
......
......@@ -44,8 +44,8 @@ import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.WeakHashMap;
import sun.awt.AppContext;
import sun.awt.datatransfer.DataTransferer;
/**
......@@ -66,10 +66,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
*/
private static String JavaMIME = "JAVA_DATAFLAVOR:";
/**
* System singleton which maps a thread's ClassLoader to a SystemFlavorMap.
*/
private static final WeakHashMap<ClassLoader, FlavorMap> flavorMaps = new WeakHashMap<>();
private static final Object FLAVOR_MAP_KEY = new Object();
/**
* Copied from java.util.Properties.
......@@ -183,22 +180,12 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
* Returns the default FlavorMap for this thread's ClassLoader.
*/
public static FlavorMap getDefaultFlavorMap() {
ClassLoader contextClassLoader =
Thread.currentThread().getContextClassLoader();
if (contextClassLoader == null) {
contextClassLoader = ClassLoader.getSystemClassLoader();
}
FlavorMap fm;
synchronized(flavorMaps) {
fm = flavorMaps.get(contextClassLoader);
if (fm == null) {
fm = new SystemFlavorMap();
flavorMaps.put(contextClassLoader, fm);
}
AppContext context = AppContext.getAppContext();
FlavorMap fm = (FlavorMap) context.get(FLAVOR_MAP_KEY);
if (fm == null) {
fm = new SystemFlavorMap();
context.put(FLAVOR_MAP_KEY, fm);
}
return fm;
}
......@@ -239,26 +226,11 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
}
});
BufferedReader flavormapURL =
String url =
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<BufferedReader>() {
public BufferedReader run() {
String url = Toolkit.getProperty("AWT.DnD.flavorMapFileURL", null);
if (url == null) {
return null;
}
try {
return new BufferedReader
(new InputStreamReader
(new URL(url).openStream(), "ISO-8859-1"));
} catch (MalformedURLException e) {
System.err.println("MalformedURLException:" + e + " while reading AWT.DnD.flavorMapFileURL:" + url);
} catch (IOException e) {
System.err.println("IOException:" + e + " while reading AWT.DnD.flavorMapFileURL:" + url);
}
return null;
new java.security.PrivilegedAction<String>() {
public String run() {
return Toolkit.getProperty("AWT.DnD.flavorMapFileURL", null);
}
});
......@@ -270,6 +242,19 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
}
}
BufferedReader flavormapURL = null;
if (url != null) {
try {
flavormapURL = new BufferedReader(new InputStreamReader(new URL(url).openStream(), "ISO-8859-1"));
} catch (MalformedURLException e) {
System.err.println("MalformedURLException:" + e + " while reading AWT.DnD.flavorMapFileURL:" + url);
} catch (IOException e) {
System.err.println("IOException:" + e + " while reading AWT.DnD.flavorMapFileURL:" + url);
} catch (SecurityException e) {
// ignored
}
}
if (flavormapURL != null) {
try {
parseAndStoreReader(flavormapURL);
......
......@@ -687,6 +687,8 @@ class JarVerifier {
} else {
matchUnsigned = true;
}
} else {
matchUnsigned = true;
}
}
......@@ -789,23 +791,7 @@ class JarVerifier {
// true if file is part of the signature mechanism itself
static boolean isSigningRelated(String name) {
name = name.toUpperCase(Locale.ENGLISH);
if (!name.startsWith("META-INF/")) {
return false;
}
name = name.substring(9);
if (name.indexOf('/') != -1) {
return false;
}
if (name.endsWith(".DSA")
|| name.endsWith(".RSA")
|| name.endsWith(".SF")
|| name.endsWith(".EC")
|| name.startsWith("SIG-")
|| name.equals("MANIFEST.MF")) {
return true;
}
return false;
return SignatureFileVerifier.isSigningRelated(name);
}
private Enumeration<String> unsignedEntryNames(JarFile jar) {
......
......@@ -28,8 +28,11 @@ package javax.sql.rowset;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.sql.SQLException;
import java.util.PropertyPermission;
import java.util.ServiceConfigurationError;
import java.util.ServiceLoader;
import javax.sql.rowset.spi.SyncFactoryException;
import sun.reflect.misc.ReflectUtil;
/**
* A factory API that enables applications to obtain a
......@@ -129,15 +132,11 @@ public class RowSetProvider {
factoryClassName = getSystemProperty(ROWSET_FACTORY_NAME);
if (factoryClassName != null) {
trace("Found system property, value=" + factoryClassName);
factory = (RowSetFactory) getFactoryClass(factoryClassName, null, true).newInstance();
factory = (RowSetFactory) ReflectUtil.newInstance(getFactoryClass(factoryClassName, null, true));
}
} catch (ClassNotFoundException e) {
throw new SQLException(
"RowSetFactory: " + factoryClassName + " not found", e);
} catch (Exception e) {
throw new SQLException(
"RowSetFactory: " + factoryClassName + " could not be instantiated: " + e,
e);
} catch (Exception e) {
throw new SQLException( "RowSetFactory: " + factoryClassName +
" could not be instantiated: ", e);
}
// Check to see if we found the RowSetFactory via a System property
......@@ -182,6 +181,16 @@ public class RowSetProvider {
throws SQLException {
trace("***In newInstance()");
if(factoryClassName == null) {
throw new SQLException("Error: factoryClassName cannot be null");
}
try {
ReflectUtil.checkPackageAccess(factoryClassName);
} catch (java.security.AccessControlException e) {
throw new SQLException("Access Exception",e);
}
try {
Class<?> providerClass = getFactoryClass(factoryClassName, cl, false);
RowSetFactory instance = (RowSetFactory) providerClass.newInstance();
......@@ -291,8 +300,9 @@ public class RowSetProvider {
public String run() {
return System.getProperty(propName);
}
});
}, null, new PropertyPermission(propName, "read"));
} catch (SecurityException se) {
trace("error getting " + propName + ": "+ se);
if (debug) {
se.printStackTrace();
}
......
......@@ -27,6 +27,7 @@ package javax.sql.rowset.serial;
import java.sql.*;
import java.util.Arrays;
import java.util.Map;
import sun.reflect.misc.ReflectUtil;
/**
* An input stream used for custom mapping user-defined types (UDTs).
......@@ -476,13 +477,9 @@ public class SQLInputImpl implements SQLInput {
// create new instance of the class
SQLData obj = null;
try {
obj = (SQLData)c.newInstance();
} catch (java.lang.InstantiationException ex) {
throw new SQLException("Unable to instantiate: " +
ex.getMessage());
} catch (java.lang.IllegalAccessException ex) {
throw new SQLException("Unable to instantiate: " +
ex.getMessage());
obj = (SQLData)ReflectUtil.newInstance(c);
} catch (Exception ex) {
throw new SQLException("Unable to Instantiate: ", ex);
}
// get the attributes from the struct
Object attribs[] = s.getAttributes(map);
......
......@@ -37,8 +37,11 @@ import java.io.IOException;
import java.io.FileNotFoundException;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import javax.naming.*;
import sun.reflect.misc.ReflectUtil;
/**
* The Service Provider Interface (SPI) mechanism that generates <code>SyncProvider</code>
......@@ -329,7 +332,7 @@ public class SyncFactory {
// Local implementation class names and keys from Properties
// file, translate names into Class objects using Class.forName
// and store mappings
Properties properties = new Properties();
final Properties properties = new Properties();
if (implementations == null) {
implementations = new Hashtable<>();
......@@ -356,10 +359,11 @@ public class SyncFactory {
public String run() {
return System.getProperty("rowset.properties");
}
}, null, new PropertyPermission("rowset.properties","read"));
}, null, new PropertyPermission("rowset.properties", "read"));
} catch (Exception ex) {
System.out.println("errorget rowset.properties: " + ex);
strRowsetProperties = null;
}
};
if (strRowsetProperties != null) {
// Load user's implementation of SyncProvider
......@@ -380,14 +384,27 @@ public class SyncFactory {
ClassLoader cl = Thread.currentThread().getContextClassLoader();
try (InputStream stream =
(cl == null) ? ClassLoader.getSystemResourceAsStream(ROWSET_PROPERTIES)
: cl.getResourceAsStream(ROWSET_PROPERTIES)) {
if (stream == null) {
throw new SyncFactoryException(
"Resource " + ROWSET_PROPERTIES + " not found");
try {
AccessController.doPrivileged((PrivilegedExceptionAction<Void>) () -> {
try (InputStream stream = (cl == null) ?
ClassLoader.getSystemResourceAsStream(ROWSET_PROPERTIES)
: cl.getResourceAsStream(ROWSET_PROPERTIES)) {
if (stream == null) {
throw new SyncFactoryException("Resource " + ROWSET_PROPERTIES + " not found");
}
properties.load(stream);
}
return null;
});
} catch (PrivilegedActionException ex) {
Throwable e = ex.getException();
if (e instanceof SyncFactoryException) {
throw (SyncFactoryException) e;
} else {
SyncFactoryException sfe = new SyncFactoryException();
sfe.initCause(ex.getException());
throw sfe;
}
properties.load(stream);
}
parseProperties(properties);
......@@ -411,7 +428,7 @@ public class SyncFactory {
public String run() {
return System.getProperty(ROWSET_SYNC_PROVIDER);
}
}, null, new PropertyPermission(ROWSET_SYNC_PROVIDER,"read"));
}, null, new PropertyPermission(ROWSET_SYNC_PROVIDER, "read"));
} catch (Exception ex) {
providerImpls = null;
}
......@@ -547,6 +564,14 @@ public class SyncFactory {
return new com.sun.rowset.providers.RIOptimisticProvider();
}
try {
ReflectUtil.checkPackageAccess(providerID);
} catch (java.security.AccessControlException e) {
SyncFactoryException sfe = new SyncFactoryException();
sfe.initCause(e);
throw sfe;
}
// Attempt to invoke classname from registered SyncProvider list
Class<?> c = null;
try {
......@@ -555,7 +580,7 @@ public class SyncFactory {
/**
* The SyncProvider implementation of the user will be in
* the classpath. We need to find the ClassLoader which loads
* this SyncFactory and try to laod the SyncProvider class from
* this SyncFactory and try to load the SyncProvider class from
* there.
**/
c = Class.forName(providerID, true, cl);
......
......@@ -87,7 +87,7 @@ public class ClipboardTransferable implements Transferable {
HashMap cached_data = new HashMap(formats.length, 1.0f);
Map flavorsForFormats = DataTransferer.getInstance().
getFlavorsForFormats(formats, SunClipboard.flavorMap);
getFlavorsForFormats(formats, SunClipboard.getDefaultFlavorTable());
for (Iterator iter = flavorsForFormats.keySet().iterator();
iter.hasNext(); )
{
......
......@@ -64,9 +64,6 @@ import sun.awt.EventListenerAggregate;
public abstract class SunClipboard extends Clipboard
implements PropertyChangeListener {
public static final FlavorTable flavorMap =
(FlavorTable)SystemFlavorMap.getDefaultFlavorMap();
private AppContext contentsContext = null;
private final Object CLIPBOARD_FLAVOR_LISTENER_KEY;
......@@ -172,7 +169,7 @@ public abstract class SunClipboard extends Clipboard
long[] formats = getClipboardFormatsOpenClose();
return DataTransferer.getInstance().
getFlavorsForFormatsAsArray(formats, flavorMap);
getFlavorsForFormatsAsArray(formats, getDefaultFlavorTable());
}
/**
......@@ -218,7 +215,7 @@ public abstract class SunClipboard extends Clipboard
long[] formats = getClipboardFormats();
Long lFormat = (Long)DataTransferer.getInstance().
getFlavorsForFormats(formats, flavorMap).get(flavor);
getFlavorsForFormats(formats, getDefaultFlavorTable()).get(flavor);
if (lFormat == null) {
throw new UnsupportedFlavorException(flavor);
......@@ -349,7 +346,7 @@ public abstract class SunClipboard extends Clipboard
private static Set formatArrayAsDataFlavorSet(long[] formats) {
return (formats == null) ? null :
DataTransferer.getInstance().
getFlavorsForFormatsAsSet(formats, flavorMap);
getFlavorsForFormatsAsSet(formats, getDefaultFlavorTable());
}
......@@ -469,4 +466,7 @@ public abstract class SunClipboard extends Clipboard
}
}
public static FlavorTable getDefaultFlavorTable() {
return (FlavorTable) SystemFlavorMap.getDefaultFlavorMap();
}
}
......@@ -90,9 +90,6 @@ public class Main {
private static final String META_INF = "META-INF/";
// prefix for new signature-related files in META-INF directory
private static final String SIG_PREFIX = META_INF + "SIG-";
private static final Class<?>[] PARAM_STRING = { String.class };
private static final String NONE = "NONE";
......@@ -1522,22 +1519,7 @@ public class Main {
* . META-INF/*.EC
*/
private boolean signatureRelated(String name) {
String ucName = name.toUpperCase(Locale.ENGLISH);
if (ucName.equals(JarFile.MANIFEST_NAME) ||
ucName.equals(META_INF) ||
(ucName.startsWith(SIG_PREFIX) &&
ucName.indexOf("/") == ucName.lastIndexOf("/"))) {
return true;
}
if (ucName.startsWith(META_INF) &&
SignatureFileVerifier.isBlockOrSF(ucName)) {
// .SF/.DSA/.RSA/.EC files in META-INF subdirs
// are not considered signature-related
return (ucName.indexOf("/") == ucName.lastIndexOf("/"));
}
return false;
return SignatureFileVerifier.isSigningRelated(name);
}
Map<CodeSigner,String> cacheForSignerInfo = new IdentityHashMap<>();
......
......@@ -152,6 +152,52 @@ public class SignatureFileVerifier {
return false;
}
/**
* Yet another utility method used by JarVerifier and JarSigner
* to determine what files are signature related, which includes
* the MANIFEST, SF files, known signature block files, and other
* unknown signature related files (those starting with SIG- with
* an optional [A-Z0-9]{1,3} extension right inside META-INF).
*
* @param s file name
* @return true if the input file name is signature related
*/
public static boolean isSigningRelated(String name) {
name = name.toUpperCase(Locale.ENGLISH);
if (!name.startsWith("META-INF/")) {
return false;
}
name = name.substring(9);
if (name.indexOf('/') != -1) {
return false;
}
if (isBlockOrSF(name) || name.equals("MANIFEST.MF")) {
return true;
} else if (name.startsWith("SIG-")) {
// check filename extension
// see http://docs.oracle.com/javase/7/docs/technotes/guides/jar/jar.html#Digital_Signatures
// for what filename extensions are legal
int extIndex = name.lastIndexOf('.');
if (extIndex != -1) {
String ext = name.substring(extIndex + 1);
// validate length first
if (ext.length() > 3 || ext.length() < 1) {
return false;
}
// then check chars, must be in [a-zA-Z0-9] per the jar spec
for (int index = 0; index < ext.length(); index++) {
char cc = ext.charAt(index);
// chars are promoted to uppercase so skip lowercase checks
if ((cc < 'A' || cc > 'Z') && (cc < '0' || cc > '9')) {
return false;
}
}
}
return true; // no extension is OK
}
return false;
}
/** get digest from cache */
private MessageDigest getDigest(String algorithm)
......
......@@ -435,9 +435,7 @@ DGifGetImageDesc(GifFileType * GifFile) {
Private->PixelCount = (long)GifFile->Image.Width *
(long)GifFile->Image.Height;
DGifSetupDecompress(GifFile); /* Reset decompress algorithm parameters. */
return GIF_OK;
return DGifSetupDecompress(GifFile); /* Reset decompress algorithm parameters. */
}
/******************************************************************************
......
......@@ -228,6 +228,49 @@ getMlibEdgeHint(jint edgeHint) {
}
}
/*
* We have to make sure that awt_setPixels can be safely applied to the given pair of
* raster and mlib image.
*
* In particular, make sure that
* - dimension is the same
* - number of channels in mlib image corresponds to the number of bands in the raster
* - sample size in image and raster are the same.
*
* Returns:
* -1 to indicate failure,
* 1 to indicate success
*/
static int setPixelsFormMlibImage(JNIEnv *env, RasterS_t *rasterP, mlib_image* img) {
if (rasterP->width != img->width || rasterP->height != img->height) {
/* dimension does not match */
return -1;
}
if (rasterP->numBands != img->channels) {
/* number of bands does not match */
return -1;
}
switch (rasterP->dataType) {
case BYTE_DATA_TYPE:
if (img->type != MLIB_BYTE) {
return -1;
}
break;
case SHORT_DATA_TYPE:
if (img->type != MLIB_SHORT && img->type != MLIB_USHORT) {
return -1;
}
break;
default:
/* awt_setPixels does not support such rasters */
return -1;
}
return awt_setPixels(env, rasterP, mlib_ImageGetData(img));
}
/***************************************************************************
* External Functions *
***************************************************************************/
......@@ -700,7 +743,9 @@ Java_sun_awt_image_ImagingLib_convolveRaster(JNIEnv *env, jobject this,
/* Means that we couldn't write directly into the destination buffer */
if (ddata == NULL) {
retStatus = awt_setPixels(env, dstRasterP, mlib_ImageGetData(dst));
if (storeRasterArray(env, srcRasterP, dstRasterP, dst) < 0) {
retStatus = setPixelsFormMlibImage(env, dstRasterP, dst);
}
}
/* Release the pinned memory */
......@@ -1106,7 +1151,7 @@ fprintf(stderr,"Flags : %d\n",dst->flags);
if (ddata == NULL) {
/* Need to store it back into the array */
if (storeRasterArray(env, srcRasterP, dstRasterP, dst) < 0) {
retStatus = awt_setPixels(env, dstRasterP, mlib_ImageGetData(dst));
retStatus = setPixelsFormMlibImage(env, dstRasterP, dst);
}
}
......@@ -1432,6 +1477,14 @@ Java_sun_awt_image_ImagingLib_lookupByteBI(JNIEnv *env, jobject thisLib,
retStatus = 0;
}
/* Release the LUT */
for (i=0; i < lut_nbands; i++) {
(*env)->ReleasePrimitiveArrayCritical(env, jtable[i].jArray,
(jbyte *) jtable[i].table, JNI_ABORT);
}
free ((void *) jtable);
free ((void *) tbl);
/*
* Means that we couldn't write directly into
* the destination buffer
......@@ -1445,13 +1498,6 @@ Java_sun_awt_image_ImagingLib_lookupByteBI(JNIEnv *env, jobject thisLib,
}
}
/* Release the LUT */
for (i=0; i < lut_nbands; i++) {
(*env)->ReleasePrimitiveArrayCritical(env, jtable[i].jArray,
(jbyte *) jtable[i].table, JNI_ABORT);
}
free ((void *) jtable);
free ((void *) tbl);
/* Release the pinned memory */
freeArray(env, srcImageP, src, sdata, dstImageP, dst, ddata);
......@@ -1669,18 +1715,20 @@ Java_sun_awt_image_ImagingLib_lookupByteRaster(JNIEnv *env,
retStatus = 0;
}
/* Release the LUT */
for (i=0; i < lut_nbands; i++) {
(*env)->ReleasePrimitiveArrayCritical(env, jtable[i].jArray,
(jbyte *) jtable[i].table, JNI_ABORT);
}
/*
* Means that we couldn't write directly into
* the destination buffer
*/
if (ddata == NULL) {
retStatus = awt_setPixels(env, dstRasterP, mlib_ImageGetData(dst));
}
/* Release the LUT */
for (i=0; i < lut_nbands; i++) {
(*env)->ReleasePrimitiveArrayCritical(env, jtable[i].jArray,
(jbyte *) jtable[i].table, JNI_ABORT);
if (storeRasterArray(env, srcRasterP, dstRasterP, dst) < 0) {
retStatus = setPixelsFormMlibImage(env, dstRasterP, dst);
}
}
/* Release the pinned memory */
......@@ -2640,7 +2688,7 @@ storeImageArray(JNIEnv *env, BufImageS_t *srcP, BufImageS_t *dstP,
}
}
else if (mlibImP->type == MLIB_SHORT) {
return awt_setPixels(env, rasterP, mlibImP->data);
return setPixelsFormMlibImage(env, rasterP, mlibImP);
}
}
else {
......
......@@ -86,7 +86,7 @@ public final class XClipboard extends SunClipboard implements OwnershipListener
protected synchronized void setContentsNative(Transferable contents) {
SortedMap<Long,DataFlavor> formatMap =
DataTransferer.getInstance().getFormatsForTransferable
(contents, DataTransferer.adaptFlavorMap(flavorMap));
(contents, DataTransferer.adaptFlavorMap(getDefaultFlavorTable()));
long[] formats = DataTransferer.keysToLongArray(formatMap);
if (!selection.setOwner(contents, formatMap, formats,
......@@ -125,7 +125,7 @@ public final class XClipboard extends SunClipboard implements OwnershipListener
private void checkChangeHere(Transferable contents) {
if (areFlavorListenersRegistered()) {
checkChange(DataTransferer.getInstance().
getFormatsForTransferableAsArray(contents, flavorMap));
getFormatsForTransferableAsArray(contents, getDefaultFlavorTable()));
}
}
......
......@@ -63,7 +63,6 @@ public class WClipboard extends SunClipboard {
}
protected void setContentsNative(Transferable contents) {
// Don't use delayed Clipboard rendering for the Transferable's data.
// If we did that, we would call Transferable.getTransferData on
// the Toolkit thread, which is a security hole.
......@@ -72,7 +71,7 @@ public class WClipboard extends SunClipboard {
// translated. Then, for each format, translate the data and post
// it to the Clipboard.
Map <Long, DataFlavor> formatMap = WDataTransferer.getInstance().
getFormatsForTransferable(contents, flavorMap);
getFormatsForTransferable(contents, getDefaultFlavorTable());
openClipboard(this);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册