/** * Fills 'dst' with bytes from 'in', throwing EOFException if insufficient bytes are available. */ public static void readFully(InputStream in, byte[] dst) throws IOException { readFully(in, dst, 0, dst.length); }
public final void readFully(byte[] dst, int offset, int byteCount) throws IOException { Streams.readFully(in, dst, offset, byteCount); }
public final int readInt() throws IOException { Streams.readFully(in, scratch, 0, SizeOf.INT); return Memory.peekInt(scratch, 0, ByteOrder.BIG_ENDIAN); }
public final short readShort() throws IOException { Streams.readFully(in, scratch, 0, SizeOf.SHORT); return Memory.peekShort(scratch, 0, ByteOrder.BIG_ENDIAN); }
public final long readLong() throws IOException { Streams.readFully(in, scratch, 0, SizeOf.LONG); return Memory.peekLong(scratch, 0, ByteOrder.BIG_ENDIAN); }
@Implementation public static MemoryMappedFile mmapRO(String path) throws Throwable { if (path.endsWith(TZ_DATA_1) || path.endsWith(TZ_DATA_2) || path.endsWith(TZ_DATA_3)) { InputStream is = MemoryMappedFile.class.getResourceAsStream(TZ_DATA_2); if (is == null) { throw (Throwable) exceptionClass().getConstructor(String.class, int.class) .newInstance("open", -1); } try { MemoryMappedFile memoryMappedFile = new MemoryMappedFile(0L, 0L); ShadowMemoryMappedFile shadowMemoryMappedFile = Shadow.extract(memoryMappedFile); shadowMemoryMappedFile.bytes = Streams.readFully(is); return memoryMappedFile; } catch (IOException e) { throw (Throwable) exceptionClass().getConstructor(String.class, int.class, Throwable.class) .newInstance("mmap", -1, e); } } else { throw new IllegalArgumentException("Unknown file for mmap: '" + path); } }
InputStream is = super.getInputStream(manifestEntry); if (verifier != null) { verifier.addMetaEntry(manifestEntry.getName(), Streams.readFully(is)); is = super.getInputStream(manifestEntry);
Streams.readFully(ois, nextBytes, nextBIndex, HASHBYTES_TO_USE - nextBIndex);
Class<?> createClass(InputStream is, String packageName, String origName) { if (is == null) { return null; } byte[] clBuf; try { clBuf = Streams.readFully(is); } catch (IOException e) { return null; } if (packageName != null) { String packageDotName = packageName.replace('/', '.'); Package packageObj = getPackage(packageDotName); if (packageObj == null) { definePackage(packageDotName, null, null, null, null, null, null, null); } else { if (packageObj.isSealed()) { throw new SecurityException("Package is sealed"); } } } return defineClass(origName, clBuf, 0, clBuf.length, new CodeSource(codeSourceUrl, (Certificate[]) null)); }
private static byte[] getRandomBytes(int byteCount) { if (byteCount <= 0) { throw new IllegalArgumentException("Too few bytes requested: " + byteCount); } BlockGuard.Policy originalPolicy = BlockGuard.getThreadPolicy(); try { BlockGuard.setThreadPolicy(BlockGuard.LAX_POLICY); byte[] result = new byte[byteCount]; Streams.readFully(devURandom, result, 0, byteCount); return result; } catch (Exception ex) { throw new ProviderException("Couldn't read " + byteCount + " random bytes", ex); } finally { BlockGuard.setThreadPolicy(originalPolicy); } } }
private void readAndVerifyDataDescriptor(int inB, int out) throws IOException { if (hasDD) { Streams.readFully(in, hdrBuf, 0, EXTHDR); int sig = Memory.peekInt(hdrBuf, 0, ByteOrder.LITTLE_ENDIAN); if (sig != (int) EXTSIG) { throw new ZipException(String.format("unknown format (EXTSIG=%x)", sig)); } currentEntry.crc = ((long) Memory.peekInt(hdrBuf, EXTCRC, ByteOrder.LITTLE_ENDIAN)) & 0xffffffffL; currentEntry.compressedSize = ((long) Memory.peekInt(hdrBuf, EXTSIZ, ByteOrder.LITTLE_ENDIAN)) & 0xffffffffL; currentEntry.size = ((long) Memory.peekInt(hdrBuf, EXTLEN, ByteOrder.LITTLE_ENDIAN)) & 0xffffffffL; } if (currentEntry.crc != crc.getValue()) { throw new ZipException("CRC mismatch"); } if (currentEntry.compressedSize != inB || currentEntry.size != out) { throw new ZipException("Size mismatch"); } }
try { InputStream is = jf.getInputStream(entry); clBuf = Streams.readFully(is); } catch (IOException e) { return null;
throw new CertificateException("Bad Certificate encoding"); Streams.readFully(inStream, encoding); Certificate res = (Certificate) CERT_CACHE.get(hash, encoding); if (res != null) {
signed = true; InputStream is = super.getInputStream(entry); verifier.addMetaEntry(entryName, Streams.readFully(is));
ZipEntry(byte[] cdeHdrBuf, InputStream cdStream) throws IOException { Streams.readFully(cdStream, cdeHdrBuf, 0, cdeHdrBuf.length); Streams.readFully(cdStream, nameBytes, 0, nameBytes.length); if (containsNulByte(nameBytes)) { throw new ZipException("Filename contains NUL byte: " + Arrays.toString(nameBytes)); Streams.readFully(cdStream, extra, 0, extraLength); Streams.readFully(cdStream, commentBytes, 0, commentByteCount); comment = new String(commentBytes, 0, commentBytes.length, StandardCharsets.UTF_8);
Streams.readFully(in, hdrBuf, 0, 4); int hdr = Memory.peekInt(hdrBuf, 0, ByteOrder.LITTLE_ENDIAN); if (hdr == CENSIG) { Streams.readFully(in, hdrBuf, 0, (LOCHDR - LOCVER)); int version = peekShort(0) & 0xff; if (version > ZIPLocalHeaderVersionNeeded) { Streams.readFully(in, nameBuf, 0, nameLength); currentEntry = createZipEntry(ModifiedUtf8.decode(nameBuf, charBuf, 0, nameLength)); currentEntry.time = ceLastModifiedTime; Streams.readFully(in, extraData, 0, extraLength); currentEntry.setExtra(extraData);
throw new CRLException("Bad CRL encoding"); Streams.readFully(inStream, encoding); CRL res = (CRL) CRL_CACHE.get(hash, encoding); if (res != null) {
/** * Fills 'dst' with bytes from 'in', throwing EOFException if insufficient bytes are available. */ public static void readFully(InputStream in, byte[] dst) throws IOException { readFully(in, dst, 0, dst.length); }
/** * Fills 'dst' with bytes from 'in', throwing EOFException if insufficient bytes are available. */ public static void readFully(InputStream in, byte[] dst) throws IOException { readFully(in, dst, 0, dst.length); }
/** * Fills 'dst' with bytes from 'in', throwing EOFException if insufficient bytes are available. */ public static void readFully(InputStream in, byte[] dst) throws IOException { readFully(in, dst, 0, dst.length); }