[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-2d-dev
Subject:    Re: [OpenJDK 2D-Dev] RFR: 8149120: TIFFField constructor throws ArrayIndexOutOfBoundsException and I
From:       Phil Race <philip.race () oracle ! com>
Date:       2016-02-10 19:50:54
Message-ID: 56BB949E.80809 () oracle ! com
[Download RAW message or body]

+1

-phil.

On 02/09/2016 11:35 AM, Brian Burkhalter wrote:
> Please review at your convenience.
>
> Issue:https://bugs.openjdk.java.net/browse/JDK-8149120
> Patch:see below
>
> Summary: Clean up parameter checking for 
> TIFFField(TIFFTag,int,int,Object).
>
> Thanks,
>
> Brian
>
> --- 
> a/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java
> +++ 
> b/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java
> @@ -519,6 +519,11 @@
>       * @throws IllegalArgumentException if <code>type</code> is an 
> unacceptable
>       * data type for the supplied <code>TIFFTag</code>.
>       * @throws IllegalArgumentException if 
> <code>count&nbsp;&lt;&nbsp;0</code>.
> *+     * @throws IllegalArgumentException if 
> <code>count&nbsp;&lt;&nbsp;1</code>*
> *+     * and <code>type</code> is <code>TIFF_RATIONAL</code> or*
> *+     * <code>TIFF_SRATIONAL</code>.*
> *+     * @throws IllegalArgumentException if 
> <code>count&nbsp;&ne;&nbsp;1</code>*
> *+     * and <code>type</code> is <code>TIFF_IFD_POINTER</code>.*
>       * @throws NullPointerException if 
> <code>data&nbsp;==&nbsp;null</code>.
>       * @throws IllegalArgumentException if <code>data</code> is an 
> instance of
>       * a class incompatible with the specified type.
> @@ -534,6 +539,14 @@
> + " for " + tag.getName() + " tag");
>          } else if(count < 0) {
> throw new IllegalArgumentException("count < 0!");
> *+        } else if((type == TIFFTag.TIFF_RATIONAL*
> *+       || type == TIFFTag.TIFF_SRATIONAL)*
> *+     && count < 1) {*
> *+ throw new IllegalArgumentException*
> *+   ("Type is TIFF_RATIONAL or TIFF_SRATIONAL and count < 1");*
> *+        } else if (type == TIFFTag.TIFF_IFD_POINTER && count != 1) {*
> *+ throw new IllegalArgumentException*
> *+   ("Type is TIFF_IFD_POINTER count != 1");*
>          } else if(data == null) {
> throw new NullPointerException("data == null!");
>          }
>


[Attachment #3 (text/html)]

<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">+1<br>
      <br>
      -phil.<br>
      <br>
      On 02/09/2016 11:35 AM, Brian Burkhalter wrote:<br>
    </div>
    <blockquote
      cite="mid:98A4B331-7BC1-442A-AD1B-2CFA1F38D8C3@oracle.com"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html;
        charset=ISO-8859-1">
      Please review at your convenience.
      <div><br>
      </div>
      <div>Issue:<span class="Apple-tab-span" style="white-space:pre"> </span><a
          moz-do-not-send="true"
          href="https://bugs.openjdk.java.net/browse/JDK-8149120">https://bugs.openjdk.java.net/browse/JDK-8149120</a></div>
                
      <div>Patch:<span class="Apple-tab-span" style="white-space:pre"> </span>see
        below</div>
      <div><br>
      </div>
      <div>Summary: Clean up parameter checking for
        TIFFField(TIFFTag,int,int,Object).</div>
      <div><br>
      </div>
      <div>Thanks,</div>
      <div><br>
      </div>
      <div>Brian</div>
      <div><br>
      </div>
      <div>
        <div style="margin: 0px;"><font face="Courier">---
a/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java</font></div>
  <div style="margin: 0px;"><font face="Courier">+++
b/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java</font></div>
  <div style="margin: 0px;"><font face="Courier">@@ -519,6 +519,11
            @@</font></div>
        <div style="margin: 0px;"><font face="Courier">&nbsp; &nbsp; &nbsp; * @throws
            IllegalArgumentException if &lt;code&gt;type&lt;/code&gt; is
            an unacceptable</font></div>
        <div style="margin: 0px;"><font face="Courier">&nbsp; &nbsp; &nbsp; * data \
                type
            for the supplied &lt;code&gt;TIFFTag&lt;/code&gt;.</font></div>
        <div style="margin: 0px;"><font face="Courier">&nbsp; &nbsp; &nbsp; * @throws
            IllegalArgumentException if
            &lt;code&gt;count&amp;nbsp;&amp;lt;&amp;nbsp;0&lt;/code&gt;.</font></div>
        <div style="margin: 0px;"><font face="Courier"><b>+ &nbsp; &nbsp; *
              @throws IllegalArgumentException if
              &lt;code&gt;count&amp;nbsp;&amp;lt;&amp;nbsp;1&lt;/code&gt;</b></font></div>
                
        <div style="margin: 0px;"><font face="Courier"><b>+ &nbsp; &nbsp; * and
              &lt;code&gt;type&lt;/code&gt; is
              &lt;code&gt;TIFF_RATIONAL&lt;/code&gt; or</b></font></div>
        <div style="margin: 0px;"><font face="Courier"><b>+ &nbsp; &nbsp; *
              &lt;code&gt;TIFF_SRATIONAL&lt;/code&gt;.</b></font></div>
        <div style="margin: 0px;"><font face="Courier"><b>+ &nbsp; &nbsp; *
              @throws IllegalArgumentException if
              &lt;code&gt;count&amp;nbsp;&amp;ne;&amp;nbsp;1&lt;/code&gt;</b></font></div>
                
        <div style="margin: 0px;"><font face="Courier"><b>+ &nbsp; &nbsp; * and
              &lt;code&gt;type&lt;/code&gt; is
              &lt;code&gt;TIFF_IFD_POINTER&lt;/code&gt;.</b></font></div>
        <div style="margin: 0px;"><font face="Courier">&nbsp; &nbsp; &nbsp; * @throws
            NullPointerException if
            &lt;code&gt;data&amp;nbsp;==&amp;nbsp;null&lt;/code&gt;.</font></div>
        <div style="margin: 0px;"><font face="Courier">&nbsp; &nbsp; &nbsp; * @throws
            IllegalArgumentException if &lt;code&gt;data&lt;/code&gt; is
            an instance of</font></div>
        <div style="margin: 0px;"><font face="Courier">&nbsp; &nbsp; &nbsp; * a class
            incompatible with the specified type.</font></div>
        <div style="margin: 0px;"><font face="Courier">@@ -534,6 +539,14
            @@</font></div>
        <div style="margin: 0px;"><font face="Courier">&nbsp;&nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  + " for " + tag.getName() + " tag");</font></div>
        <div style="margin: 0px;"><font face="Courier">&nbsp;&nbsp; &nbsp; &nbsp; \
&nbsp; } else  if(count &lt; 0) {</font></div>
        <div style="margin: 0px;"><font face="Courier">&nbsp;&nbsp; &nbsp; &nbsp; \
                &nbsp; &nbsp; &nbsp;
            throw new IllegalArgumentException("count &lt; 0!");</font></div>
        <div style="margin: 0px;"><font face="Courier"><b>+&nbsp; &nbsp; &nbsp; \
&nbsp; }  else if((type == TIFFTag.TIFF_RATIONAL</b></font></div>
        <div style="margin: 0px;"><font face="Courier"><b>+ &nbsp; &nbsp; &nbsp; \
                &nbsp; &nbsp; &nbsp;
              &nbsp; &nbsp; &nbsp; || type == \
                TIFFTag.TIFF_SRATIONAL)</b></font></div>
        <div style="margin: 0px;"><font face="Courier"><b>+&nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp;  &nbsp; &nbsp; &amp;&amp; count &lt; 1) \
                {</b></font></div>
        <div style="margin: 0px;"><font face="Courier"><b>+&nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp;  throw new IllegalArgumentException</b></font></div>
        <div style="margin: 0px;"><font face="Courier"><b>+&nbsp; &nbsp; &nbsp; \
                &nbsp; &nbsp; &nbsp; &nbsp;
              &nbsp; ("Type is TIFF_RATIONAL or TIFF_SRATIONAL and count &lt;
              1");</b></font></div>
        <div style="margin: 0px;"><font face="Courier"><b>+&nbsp; &nbsp; &nbsp; \
&nbsp; }  else if (type == TIFFTag.TIFF_IFD_POINTER &amp;&amp; count
              != 1) {</b></font></div>
        <div style="margin: 0px;"><font face="Courier"><b>+&nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp;  throw new IllegalArgumentException</b></font></div>
        <div style="margin: 0px;"><font face="Courier"><b>+&nbsp; &nbsp; &nbsp; \
                &nbsp; &nbsp; &nbsp; &nbsp;
              &nbsp; ("Type is TIFF_IFD_POINTER count != 1");</b></font></div>
        <div style="margin: 0px;"><font face="Courier">&nbsp;&nbsp; &nbsp; &nbsp; \
&nbsp; } else  if(data == null) {</font></div>
        <div style="margin: 0px;"><font face="Courier">&nbsp;&nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp;  throw new NullPointerException("data == null!");</font></div>
        <div style="margin: 0px;"><font face="Courier">&nbsp;&nbsp; &nbsp; &nbsp; \
&nbsp; }</font></div>  </div>
      <div><br>
      </div>
    </blockquote>
    <br>
  </body>
</html>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic