dis.close(); CryptoAPIDocumentInputStream sbis = new CryptoAPIDocumentInputStream(this, bos.toByteArray()); LittleEndianInputStream leis = new LittleEndianInputStream(sbis); POIFSFileSystem fsOut = null; try { int streamDescriptorArrayOffset = (int) leis.readUInt(); /* int streamDescriptorArraySize = (int) */ leis.readUInt(); long skipN = streamDescriptorArrayOffset - 8L; if (sbis.skip(skipN) < skipN) { int encryptedStreamDescriptorCount = (int) leis.readUInt(); StreamDescriptorEntry entries[] = new StreamDescriptorEntry[encryptedStreamDescriptorCount]; for (int i = 0; i < encryptedStreamDescriptorCount; i++) { StreamDescriptorEntry entry = new StreamDescriptorEntry(); entries[i] = entry; entry.streamOffset = (int) leis.readUInt(); entry.streamSize = (int) leis.readUInt(); entry.block = leis.readUShort(); int nameSize = leis.readUByte(); entry.flags = leis.readUByte(); entry.reserved2 = leis.readInt(); entry.streamName = StringUtil.readUnicodeLE(leis, nameSize); leis.readShort(); assert(entry.streamName.length() == nameSize);
throws NoPropertySetStreamException, MarkUnsupportedException, UnsupportedEncodingException, IOException { stream.mark(PropertySet.OFFSET_HEADER+ClassID.LENGTH+1); LittleEndianInputStream leis = new LittleEndianInputStream(stream); int byteOrder = leis.readUShort(); int format = leis.readUShort(); /*int osVersion = (int)*/leis.readUInt(); byte[] clsIdBuf = new byte[ClassID.LENGTH]; leis.readFully(clsIdBuf); int sectionCount = (int)leis.readUInt(); leis.readFully(clsIdBuf);
private void nextChunk() throws GeneralSecurityException, IOException { if (chunkSize != -1) { int index = (int)(pos >> chunkBits); initCipherForBlock(cipher, index); if (lastIndex != index) { long skipN = (index - lastIndex) << chunkBits; if (super.skip(skipN) < skipN) { throw new EOFException("buffer underrun"); } } lastIndex = index + 1; } final int todo = (int)Math.min(size, chunk.length); int readBytes, totalBytes = 0; do { readBytes = super.read(plain, totalBytes, todo-totalBytes); totalBytes += Math.max(0, readBytes); } while (readBytes != -1 && totalBytes < todo); if (readBytes == -1 && pos+totalBytes < size && size < Integer.MAX_VALUE) { throw new EOFException("buffer underrun"); } System.arraycopy(plain, 0, chunk, 0, totalBytes); invokeCipher(totalBytes, totalBytes == chunkSize); }
static LittleEndianInput getLEI(InputStream is) { if (is instanceof LittleEndianInput) { // accessing directly is an optimisation return (LittleEndianInput) is; } // less optimal, but should work OK just the same. Often occurs in junit tests. return new LittleEndianInputStream(is); }
@Override public short readShort() { return (short)readUShort(); }
public void read(byte[] data, int offset){ @SuppressWarnings("resource") LittleEndianInputStream leis = new LittleEndianInputStream( new ByteArrayInputStream(data, offset, RECORD_LENGTH)); wmfsize = leis.readInt(); int left = leis.readInt(); int top = leis.readInt(); int right = leis.readInt(); int bottom = leis.readInt(); bounds.setBounds(left, top, right-left, bottom-top); int width = leis.readInt(); int height = leis.readInt(); size.setSize(width, height); zipsize = leis.readInt(); compression = leis.readUByte(); filter = leis.readUByte(); }
public HwmfHeader(LittleEndianInputStream leis) throws IOException { type = leis.readUShort(); recordSize = leis.readUShort(); int bytesLeft = recordSize*LittleEndianConsts.SHORT_SIZE-4; version = leis.readUShort(); bytesLeft -= LittleEndianConsts.SHORT_SIZE; filesize = leis.readInt(); bytesLeft -= LittleEndianConsts.INT_SIZE; numberOfObjects = leis.readUShort(); bytesLeft -= LittleEndianConsts.SHORT_SIZE; maxRecord = leis.readUInt(); bytesLeft -= LittleEndianConsts.INT_SIZE; numberOfMembers = leis.readUShort(); bytesLeft -= LittleEndianConsts.SHORT_SIZE; long len = leis.skip(bytesLeft); assert(len == bytesLeft);
byte b2 = is.readByte(); b1 &= ~(1<<7); //unset highest bit b2 &= ~(1<<7); //unset highest bit (if it exists?) boolean halt = false; while (i < 4 && ! halt) { byte b = is.readByte(); halt = (b >> 7 & 1) == 0; //if highest bit !=1 then continue b &= ~(1<<7); is.readFully(buff); handleRecord(recordId, buff); } else { long length = is.skip(recordLength); if (length != recordLength) { throw new XSSFBParseException("End of file reached before expected.\t"+
y = leis.readShort(); x = leis.readShort(); stringLength = leis.readShort(); fwOpts = leis.readUShort(); left = leis.readShort(); top = leis.readShort(); right = leis.readShort(); bottom = leis.readShort(); size += 4*LittleEndianConsts.SHORT_SIZE; leis.readFully(rawTextBytes); size += rawTextBytes.length; dx[i] = leis.readShort(); size += LittleEndianConsts.SHORT_SIZE;
@Override public int init(LittleEndianInputStream leis, long recordSize, int recordFunction) throws IOException { layout = leis.readUShort(); // A 16-bit field that MUST be ignored. /*int reserved =*/ leis.readShort(); return 2*LittleEndianConsts.SHORT_SIZE; }
public int readUByte() { int ch; try { ch = in.read(); } catch (IOException e) { throw new RuntimeException(e); } checkEOF(ch); return ch; } public double readDouble() {
@Override public void readPlain(byte[] buf, int off, int len) { readFully(buf, off, len); } }
public int init(LittleEndianInputStream leis) throws IOException { type = leis.readShort(); width = leis.readShort(); height = leis.readShort(); widthBytes = leis.readShort(); planes = leis.readUByte(); bitsPixel = leis.readUByte(); long skipSize = leis.skip(LittleEndianConsts.INT_SIZE); assert(skipSize == LittleEndianConsts.INT_SIZE); skipSize = leis.skip(18); assert(skipSize == 18); size += 18+LittleEndianConsts.INT_SIZE;
@Override public byte readByte() { return (byte)readUByte(); }
public int init(LittleEndianInputStream leis) throws IOException { height = leis.readShort(); width = leis.readShort(); escapement = leis.readShort(); orientation = leis.readShort(); weight = leis.readShort(); italic = leis.readByte() != 0; underline = leis.readByte() != 0; strikeOut = leis.readByte() != 0; charSet = FontCharset.valueOf(leis.readUByte()); outPrecision = WmfOutPrecision.valueOf(leis.readUByte()); clipPrecision = WmfClipPrecision.valueOf(leis.readUByte()); quality = WmfFontQuality.valueOf(leis.readUByte()); pitchAndFamily = leis.readUByte(); byte buf[] = new byte[32], b, readBytes = 0; do { if (readBytes == 32) { throw new IOException("Font facename can't be determined."); } buf[readBytes++] = b = leis.readByte(); } while (b != 0 && b != -1 && readBytes <= 32); facename = new String(buf, 0, readBytes-1, StandardCharsets.ISO_8859_1); return 5*LittleEndianConsts.SHORT_SIZE+8*LittleEndianConsts.BYTE_SIZE+readBytes; }
public HwmfPicture(InputStream inputStream) throws IOException { LittleEndianInputStream leis = new LittleEndianInputStream(bis)) { placeableHeader = HwmfPlaceableHeader.readHeader(leis); header = new HwmfHeader(leis); try { long recordSizeLong = leis.readUInt()*2; if (recordSizeLong > Integer.MAX_VALUE) { throw new RecordFormatException("record size can't be > "+Integer.MAX_VALUE); recordFunction = leis.readShort(); } catch (Exception e) { logger.log(POILogger.ERROR, "unexpected eof - wmf file was truncated");
@Override public int init(LittleEndianInputStream leis, long recordSize, int recordFunction) throws IOException { stringLength = leis.readShort(); rawTextBytes = IOUtils.safelyAllocate(stringLength+(stringLength&1), MAX_RECORD_LENGTH); leis.readFully(rawTextBytes); yStart = leis.readShort(); xStart = leis.readShort(); return 3*LittleEndianConsts.SHORT_SIZE+rawTextBytes.length; }
public HemfExtractor(InputStream is) throws IOException { stream = new LittleEndianInputStream(is); header = new HemfHeader(); long recordId = stream.readUInt(); long recordSize = stream.readUInt(); header = new HemfHeader(); header.init(stream, recordId, recordSize-8); }