axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: ws-axis/java/src/org/apache/axis/components/image JDK13IO.java
Date Sun, 23 Nov 2003 03:51:59 GMT
dims        2003/11/22 19:51:59

  Modified:    java/src/org/apache/axis/attachments AttachmentPart.java
                        MultiPartRelatedInputStream.java
               java/src/org/apache/axis/message InputStreamBody.java
               java/src/org/apache/axis/components/image JDK13IO.java
  Added:       java/src/org/apache/axis/utils IOUtils.java
  Log:
  Fix for Bug 24285 - MultipartRelatedInputStream: Unreliable handling of boundaries
  
  Revision  Changes    Path
  1.39      +2 -1      ws-axis/java/src/org/apache/axis/attachments/AttachmentPart.java
  
  Index: AttachmentPart.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/attachments/AttachmentPart.java,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- AttachmentPart.java	19 Jun 2003 04:51:57 -0000	1.38
  +++ AttachmentPart.java	23 Nov 2003 03:51:59 -0000	1.39
  @@ -60,6 +60,7 @@
   import org.apache.axis.transport.http.HTTPConstants;
   import org.apache.axis.utils.Messages;
   import org.apache.axis.utils.SessionUtils;
  +import org.apache.axis.utils.IOUtils;
   import org.apache.commons.logging.Log;
   
   import javax.activation.DataHandler;
  @@ -396,7 +397,7 @@
           if (ds.getContentType().equals("text/plain")) {
               try {
                   byte[] bytes = new byte[is.available()];
  -                is.read(bytes);
  +                IOUtils.readFully(is, bytes);
                   return new String(bytes);
               } catch (java.io.IOException io) {
                   log.error(Messages.getMessage("javaIOException00"), io);
  
  
  
  1.40      +2 -1      ws-axis/java/src/org/apache/axis/attachments/MultiPartRelatedInputStream.java
  
  Index: MultiPartRelatedInputStream.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/attachments/MultiPartRelatedInputStream.java,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- MultiPartRelatedInputStream.java	26 Aug 2003 16:45:05 -0000	1.39
  +++ MultiPartRelatedInputStream.java	23 Nov 2003 03:51:59 -0000	1.40
  @@ -58,6 +58,7 @@
   import org.apache.axis.components.logger.LogFactory;
   import org.apache.axis.transport.http.HTTPConstants;
   import org.apache.axis.utils.Messages;
  +import org.apache.axis.utils.IOUtils;
   import org.apache.commons.logging.Log;
   
   import javax.activation.DataHandler;
  @@ -174,7 +175,7 @@
                   // after this we use the more efficient boundarydelimeted stream.  There
should never be any data here anyway.
                   byte[][] boundaryMarker = new byte[2][boundaryStr.length() + 2];
   
  -                stream.read(boundaryMarker[0]);
  +                IOUtils.readFully(stream, boundaryMarker[0]);
   
                   boundary = (boundaryStr + "\r\n").getBytes("US-ASCII");
   
  
  
  
  1.17      +2 -1      ws-axis/java/src/org/apache/axis/message/InputStreamBody.java
  
  Index: InputStreamBody.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/message/InputStreamBody.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- InputStreamBody.java	22 Apr 2003 19:35:15 -0000	1.16
  +++ InputStreamBody.java	23 Nov 2003 03:51:59 -0000	1.17
  @@ -58,6 +58,7 @@
   import org.apache.axis.components.logger.LogFactory;
   import org.apache.axis.encoding.SerializationContext;
   import org.apache.axis.utils.Messages;
  +import org.apache.axis.utils.IOUtils;
   import org.apache.commons.logging.Log;
   
   import java.io.IOException;
  @@ -80,7 +81,7 @@
       {
           try {
               byte[]  buf = new byte[ inputStream.available() ];
  -            inputStream.read( buf );
  +            IOUtils.readFully(inputStream,buf);
               String contents = new String(buf);
               context.writeString(contents);
           }
  
  
  
  1.1                  ws-axis/java/src/org/apache/axis/utils/IOUtils.java
  
  Index: IOUtils.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.utils;
  
  import java.io.IOException;
  import java.io.InputStream;
  
  public class IOUtils
  {
      /**
       * Helper method, just calls <tt>readFully(in, b, 0, b.length)</tt>
       */
      public static int readFully(InputStream in, byte[] b)
      throws IOException
      {
          return readFully(in, b, 0, b.length);
      }
  
      /**
       * Same as the normal <tt>in.read(b, off, len)</tt>, but tries to ensure
that
       * the entire len number of bytes is read.
       * <p>
       * If the end of file is reached before any bytes are read, returns -1.
       * Otherwise, returns the number of bytes read.
       */
      public static int readFully(InputStream in, byte[] b, int off, int len)
      throws IOException
      {
          int total = 0;
          for (;;) {
              int got = in.read(b, off + total, len - total);
              if (got < 0) {
                  return (total == 0) ? -1 : total;
              } else {
                  total += got;
                  if (total == len)
                      return total;
              }
          }
      }
  }
  
  
  1.8       +8 -3      ws-axis/java/src/org/apache/axis/components/image/JDK13IO.java
  
  Index: JDK13IO.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/components/image/JDK13IO.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- JDK13IO.java	6 Oct 2003 05:24:49 -0000	1.7
  +++ JDK13IO.java	23 Nov 2003 03:51:59 -0000	1.8
  @@ -56,9 +56,14 @@
   package org.apache.axis.components.image;
   
   import org.apache.axis.utils.Messages;
  +import org.apache.axis.utils.IOUtils;
   import sun.awt.image.codec.JPEGImageEncoderImpl;
   
  -import java.awt.*;
  +import java.awt.Component;
  +import java.awt.Graphics;
  +import java.awt.Image;
  +import java.awt.MediaTracker;
  +import java.awt.Toolkit;
   import java.awt.image.BufferedImage;
   import java.io.IOException;
   import java.io.InputStream;
  @@ -75,7 +80,7 @@
        * @param mimeType the mime-type of the format to save the image
        * @param image the image to save
        * @param os the stream to write to
  -     * @exception JimiException if an error prevents image encoding
  +     * @exception Exception if an error prevents image encoding
        */
       public void saveImage(String mimeType, Image image, OutputStream os)
               throws Exception {
  @@ -115,7 +120,7 @@
           }
           else {
               byte[] bytes = new byte[in.available()];
  -            in.read(bytes);
  +            IOUtils.readFully(in,bytes);
               return Toolkit.getDefaultToolkit().createImage(bytes);
           }
       } // loadImage
  
  
  

Mime
View raw message