In ICC_Profile.getInstance(), the method
InputStream.read(byte[],int,int) is called. But only once. The correct
way is to call it in a loop until the buffer is fully read. An
InputStream implementation is free to fill only a part of a buffer.
2008-02-12 Roman Kennke <[EMAIL PROTECTED]>
* java/awt/color/ICC_Profile.java
(getInstance()): Wrap call to InputStream.read(byte[],int,int) in
a loop, in order to read the whole thing.
/Roman
--
Dipl.-Inform. (FH) Roman Kennke, Software Engineer, http://kennke.org
aicas Allerton Interworks Computer Automated Systems GmbH
Haid-und-Neu-Straße 18 * D-76131 Karlsruhe * Germany
http://www.aicas.com * Tel: +49-721-663 968-0
USt-Id: DE216375633, Handelsregister HRB 109481, AG Karlsruhe
Geschäftsführer: Dr. James J. Hunt
Index: java/awt/color/ICC_Profile.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/awt/color/ICC_Profile.java,v
retrieving revision 1.13
diff -u -1 -0 -r1.13 ICC_Profile.java
--- java/awt/color/ICC_Profile.java 3 Oct 2005 17:21:07 -0000 1.13
+++ java/awt/color/ICC_Profile.java 12 Feb 2008 11:25:57 -0000
@@ -419,24 +419,29 @@
// verify it as a correct ICC header, but do not verify the
// size as we are reading from a stream.
header.verifyHeader(-1);
// get the size
byte[] data = new byte[header.getSize()];
System.arraycopy(headerData, 0, data, 0, ProfileHeader.HEADERSIZE);
// read the rest
- if (in.read(data, ProfileHeader.HEADERSIZE,
- header.getSize() - ProfileHeader.HEADERSIZE) != header.getSize()
- - ProfileHeader.HEADERSIZE)
- throw new IOException("Incorrect profile size");
+ int totalBytes = header.getSize() - ProfileHeader.HEADERSIZE;
+ int bytesLeft = totalBytes;
+ while (bytesLeft > 0)
+ {
+ int read = in.read(data,
+ ProfileHeader.HEADERSIZE + (totalBytes - bytesLeft),
+ bytesLeft);
+ bytesLeft -= read;
+ }
return getInstance(data);
}
/**
* Returns the major version number
*/
public int getMajorVersion()
{
return header.getMajorVersion();