Author: msahyoun
Date: Fri Feb 23 15:58:35 2018
New Revision: 1825136

URL: http://svn.apache.org/viewvc?rev=1825136&view=rev
Log:
PDFBOX-4124: get result of read and skip - LOG.debug if result differs from 
intented number of bytes 

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java
    
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/SecurityHandler.java
    
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/SampledImageReader.java

Modified: 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java?rev=1825136&r1=1825135&r2=1825136&view=diff
==============================================================================
--- 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java 
(original)
+++ 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java 
Fri Feb 23 15:58:35 2018
@@ -1913,7 +1913,12 @@ public class COSParser extends BaseParse
                     stream = parseCOSStream(dict);
                     is = stream.createInputStream();
                     numbersBytes = new byte[offsetFirstStream];
-                    is.read(numbersBytes);
+                    long isResult = is.read(numbersBytes);
+
+                    if (Long.compare(isResult, numbersBytes.length) != 0)
+                    {
+                        LOG.debug("Tried reading " + numbersBytes.length + " 
bytes but only " + isResult + " bytes read");
+                    }
                 }
                 catch (IOException exception)
                 {

Modified: 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/SecurityHandler.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/SecurityHandler.java?rev=1825136&r1=1825135&r2=1825136&view=diff
==============================================================================
--- 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/SecurityHandler.java
 (original)
+++ 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/SecurityHandler.java
 Fri Feb 23 15:58:35 2018
@@ -418,7 +418,12 @@ public abstract class SecurityHandler
             try (InputStream is = stream.createRawInputStream())
             {
                 buf = new byte[10];
-                is.read(buf);
+                long isResult = is.read(buf);
+
+                if (Long.compare(isResult, buf.length) != 0)
+                {
+                    LOG.debug("Tried reading " + buf.length + " bytes but only 
" + isResult + " bytes read");
+                }
             }
             if (Arrays.equals(buf, "<?xpacket ".getBytes(Charsets.ISO_8859_1)))
             {

Modified: 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/SampledImageReader.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/SampledImageReader.java?rev=1825136&r1=1825135&r2=1825136&view=diff
==============================================================================
--- 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/SampledImageReader.java
 (original)
+++ 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/SampledImageReader.java
 Fri Feb 23 15:58:35 2018
@@ -283,7 +283,13 @@ final class SampledImageReader
             int i = 0;
             for (int y = 0; y < height; ++y)
             {
-                input.read(tempBytes);
+                long inputResult = input.read(tempBytes);
+
+                if (Long.compare(inputResult, tempBytes.length) != 0)
+                {
+                    LOG.debug("Tried reading " + tempBytes.length + " bytes 
but only " + inputResult + " bytes read");
+                }
+
                 for (int x = 0; x < width; ++x)
                 {
                     for (int c = 0; c < numComponents; c++)


Reply via email to