jcifs-0.8.3 from tgz
authorFelix Schumacher <p0354740@isib001.(none)>
Wed, 6 Aug 2008 14:15:58 +0000 (16:15 +0200)
committerFelix Schumacher <p0354740@isib001.(none)>
Wed, 6 Aug 2008 14:15:58 +0000 (16:15 +0200)
Mon Apr 19 20:23:10 EDT 2004
jcifs-0.8.3 released / File Corruption with HotSpot

A  serious  bug was discovered in the HotSpot VM on Linux that can cause an
offset  field to be encoded incorrectly resulting in file corruption. A bug
report  has  been  submitted  and the code in question has been modified to
avoid  the  problem.  If you are using the <tt>-server</tt> option on Linux
you  must  upgrade to this version of jCIFS. Big thanks to Richard Heap for
diagnosing and fixing this very elusive issue.

13 files changed:
CHANGES.txt
README.txt
build.xml
examples/GetURL.java
examples/runtests.sh
src/jcifs/smb/AndXServerMessageBlock.java
src/jcifs/smb/ServerMessageBlock.java
src/jcifs/smb/SmbComNTCreateAndX.java
src/jcifs/smb/SmbComReadAndX.java
src/jcifs/smb/SmbComWriteAndX.java
src/jcifs/smb/SmbTransport.java
src/jcifs/smb/Trans2SetFileInformation.java
src/jcifs/util/Log.java

index 41a8cc0..6b42e95 100644 (file)
@@ -1,3 +1,13 @@
+Mon Apr 19 20:23:10 EDT 2004
+jcifs-0.8.3 released / File Corruption with HotSpot
+
+A  serious  bug was discovered in the HotSpot VM on Linux that can cause an
+offset  field to be encoded incorrectly resulting in file corruption. A bug
+report  has  been  submitted  and the code in question has been modified to
+avoid  the  problem.  If you are using the <tt>-server</tt> option on Linux
+you  must  upgrade to this version of jCIFS. Big thanks to Richard Heap for
+diagnosing and fixing this very elusive issue. 
+
 Sun Mar 14 18:54:14 EST 2004
 jcifs-0.8.2 released
 
index 9136262..5ee5a1a 100644 (file)
@@ -1,3 +1,9 @@
+Mon Apr 19 20:23:10 EDT 2004
+jcifs-0.8.3 released / File Corruption with HotSpot
+
+A serious bug was discovered in the HotSpot VM on Linux that can cause file
+corruption. It has been fixed. 
+
 Sun Mar 14 18:54:14 EST 2004
 jcifs-0.8.2 released
 
index 08af8b4..b21b08a 100644 (file)
--- a/build.xml
+++ b/build.xml
        <target name="jar" depends="smb">
                <copy file="src/jcifs/util/mime.map" tofile="build/jcifs/util/mime.map" overwrite="yes"/>
                <copy file="src/jcifs/http/ne.css" tofile="build/jcifs/http/ne.css" overwrite="yes"/>
-               <jar jarfile="jcifs-0.8.2.jar" basedir="build"/>
+               <jar jarfile="jcifs-0.8.3.jar" basedir="build"/>
        </target>
 
        <target name="tgz">
-               <copy todir="dist_tmp/jcifs_0.8.2">
+               <copy todir="dist_tmp/jcifs_0.8.3">
                        <fileset dir="." excludes="ant,**/.*,build,jcifs.prp,**/*.tgz,**/*.zip"/>
                </copy>
-               <tar tarfile="jcifs-0.8.2.tar" basedir="dist_tmp"/>
-               <gzip src="jcifs-0.8.2.tar" zipfile="jcifs-0.8.2.tgz"/>
-               <delete file="jcifs-0.8.2.tar"/>
+               <tar tarfile="jcifs-0.8.3.tar" basedir="dist_tmp"/>
+               <gzip src="jcifs-0.8.3.tar" zipfile="jcifs-0.8.3.tgz"/>
+               <delete file="jcifs-0.8.3.tar"/>
                <delete dir="dist_tmp"/>
        </target>
        <target name="zip">
-               <copy todir="dist_tmp/jcifs_0.8.2">
+               <copy todir="dist_tmp/jcifs_0.8.3">
                        <fileset dir="." excludes="ant,**/.*,build,jcifs.prp,**/*.tgz,**/*.zip"/>
                </copy>
                <fixcrlf srcdir="dist_tmp" cr="add" tab="remove" tablength="4" excludes="**/*.jar,**/*.exe"/>
-               <zip zipfile="jcifs-0.8.2.zip" basedir="dist_tmp"/>
+               <zip zipfile="jcifs-0.8.3.zip" basedir="dist_tmp"/>
                <delete dir="dist_tmp"/>
        </target>
 
index 7190fd1..0b8201c 100644 (file)
@@ -14,7 +14,7 @@ public class GetURL {
                        byte[] buf = new byte[4096];
                        int n;
                        while(( n = in.read( buf )) != -1 ) {
-                               System.out.write( buf, 0, n );
+                               System.out.print( " " + n );
                        }
                } else {
                        System.out.println( "stream waz null" );
index 0940d65..026620f 100644 (file)
@@ -31,8 +31,8 @@ $RUN GetDate ${URL_SHARE}${FILE1}
 $RUN Get ${URL_SHARE}${FILE1}
 $RUN GetType ${URL_SHARE}
 $RUN GrowWrite ${URL_WRITE_DIR}GrowWrite.txt
-$RUN GetURL ${URL_WRITE_DIR}Append.txt
-$RUN HttpURL ${URL_WRITE_DIR}Append.txt
+$RUN GetURL ${URL_WRITE_DIR}GrowWrite.txt
+$RUN HttpURL ${URL_WRITE_DIR} GrowWrite.txt
 $RUN Interleave ${URL_WRITE_DIR} 3
 $RUN IsDir ${URL_SHARE}${SRC_DIR}/
 $RUN Length ${URL_SHARE}${FILE1}
index f4f5955..6d77323 100644 (file)
@@ -71,6 +71,7 @@ abstract class AndXServerMessageBlock extends ServerMessageBlock {
                dstIndex += writeHeaderWireFormat( dst, dstIndex );
                dstIndex += writeAndXWireFormat( dst, dstIndex );
                length = dstIndex - start;
+//Log.printHexDump( System.err, Thread.currentThread().getName() + ": writeWireFormat", dst, 0, Math.min( dstIndex, 63 ));
                return length;
        }
 
@@ -133,6 +134,7 @@ abstract class AndXServerMessageBlock extends ServerMessageBlock {
                        dst[start + ANDX_OFFSET_OFFSET + 1] = (byte)0x00;
 
                        // andx not used; return
+//Log.printHexDump( System.err, Thread.currentThread().getName() + ": writeAndXWireFormat1", dst, 0, Math.min( dstIndex, 63 ));
                        return dstIndex - start;
                }
 
@@ -186,6 +188,7 @@ abstract class AndXServerMessageBlock extends ServerMessageBlock {
                        dstIndex += andx.byteCount;
                }
 
+//Log.printHexDump( System.err, Thread.currentThread().getName() + ": writeAndXWireFormat1", dst, 0, Math.min( dstIndex, 63 ));
                return dstIndex - start;
        }
        int readAndXWireFormat( InputStream in,
index af11198..77d717e 100644 (file)
@@ -115,15 +115,16 @@ abstract class ServerMessageBlock {
                (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00
        };
 
+
        static void writeInt2( long val, byte[] dst, int dstIndex ) {
-               dst[dstIndex++] = (byte)((int)(val >>> 0) & 0xFF);
-               dst[dstIndex++] = (byte)((int)(val >>> 8) & 0xFF);
+               dst[dstIndex] = (byte)(val);
+               dst[++dstIndex] = (byte)(val >> 8);
        }
        static void writeInt4( long val, byte[] dst, int dstIndex ) {
-               dst[dstIndex++] = (byte)((int)(val >>> 0) & 0xFF);
-               dst[dstIndex++] = (byte)((int)(val >>> 8) & 0xFF);
-               dst[dstIndex++] = (byte)((int)(val >>> 16) & 0xFF);
-               dst[dstIndex++] = (byte)((int)(val >>> 24) & 0xFF);
+               dst[dstIndex] = (byte)(val);
+               dst[++dstIndex] = (byte)(val >>= 8);
+               dst[++dstIndex] = (byte)(val >>= 8);
+               dst[++dstIndex] = (byte)(val >> 8);
        }
        static int readInt2( byte[] src, int srcIndex ) {
                return ( src[srcIndex] & 0xFF ) +
@@ -139,20 +140,20 @@ abstract class ServerMessageBlock {
                return (readInt4( src, srcIndex ) & 0xFFFFFFFFL) +
                        ((long)(readInt4( src, srcIndex + 4 )) << 32);
        }
-       static void writeLong( long val, byte[] dst, int dstIndex ) {
-               dst[dstIndex++] = (byte)((int)(val >>> 0) & 0xFF);
-               dst[dstIndex++] = (byte)((int)(val >>> 8) & 0xFF);
-               dst[dstIndex++] = (byte)((int)(val >>> 16) & 0xFF);
-               dst[dstIndex++] = (byte)((int)(val >>> 24) & 0xFF);
-               dst[dstIndex++] = (byte)((int)(val >>> 32) & 0xFF);
-               dst[dstIndex++] = (byte)((int)(val >>> 40) & 0xFF);
-               dst[dstIndex++] = (byte)((int)(val >>> 48) & 0xFF);
-               dst[dstIndex++] = (byte)((int)(val >>> 56) & 0xFF);
+       static void writeInt8( long val, byte[] dst, int dstIndex ) {
+               dst[dstIndex] = (byte)(val);
+               dst[++dstIndex] = (byte)(val >>= 8);
+               dst[++dstIndex] = (byte)(val >>= 8);
+               dst[++dstIndex] = (byte)(val >>= 8);
+               dst[++dstIndex] = (byte)(val >>= 8);
+               dst[++dstIndex] = (byte)(val >>= 8);
+               dst[++dstIndex] = (byte)(val >>= 8);
+               dst[++dstIndex] = (byte)(val >> 8);
        }
        static long readTime( byte[] src, int srcIndex ) {
                int low = readInt4( src, srcIndex );
                int hi = readInt4( src, srcIndex + 4 );
-               long t = ((long)hi << 32 ) | ( (long)low & 0xFFFFFFFFL );
+               long t = ((long)hi << 32L ) | (low & 0xFFFFFFFFL);
                t = ( t / 10000L - MILLISECONDS_BETWEEN_1970_AND_1601 );
 
 /*
@@ -180,8 +181,8 @@ abstract class ServerMessageBlock {
        }
        static void writeTime( long t, byte[] dst, int dstIndex ) {
 
-/*
                if( t != 0L ) {
+/*
                        synchronized( TZ ) {
                                if( TZ.inDaylightTime( new Date() )) {
                                        // in DST
@@ -201,12 +202,11 @@ abstract class ServerMessageBlock {
                                        }
                                }
                        }
-
+*/
                        t = (t + MILLISECONDS_BETWEEN_1970_AND_1601) * 10000L;
                }
-*/
 
-               writeLong( t, dst, dstIndex );
+               writeInt8( t, dst, dstIndex );
        }
        static long readUTime( byte[] buffer, int bufferIndex ) {
                return readInt4( buffer, bufferIndex ) * 1000L;
index beaa46a..2ab3c7d 100644 (file)
@@ -165,7 +165,7 @@ class SmbComNTCreateAndX extends AndXServerMessageBlock {
                dstIndex += 4;
                writeInt4( desiredAccess, dst, dstIndex );
                dstIndex += 4;
-               writeLong( allocationSize, dst, dstIndex );
+               writeInt8( allocationSize, dst, dstIndex );
                dstIndex += 8;
                writeInt4( extFileAttributes, dst, dstIndex );
                dstIndex += 4;
index b98664b..6e93c6c 100644 (file)
@@ -60,7 +60,7 @@ class SmbComReadAndX extends AndXServerMessageBlock {
 
                writeInt2( fid, dst, dstIndex );
                dstIndex += 2;
-               writeInt4( offset & 0xFFFFFFFFL, dst, dstIndex );
+               writeInt4( offset, dst, dstIndex );
                dstIndex += 4;
                writeInt2( maxCount, dst, dstIndex );
                dstIndex += 2;
@@ -70,7 +70,7 @@ class SmbComReadAndX extends AndXServerMessageBlock {
                dstIndex += 4;
                writeInt2( remaining, dst, dstIndex );
                dstIndex += 2;
-               writeInt4(( offset >> 32 ) & 0xFFFFFFFFL, dst, dstIndex );
+               writeInt4( offset >> 32, dst, dstIndex );
                dstIndex += 4;
 
                return dstIndex - start;
index 8f751b2..724503c 100644 (file)
@@ -84,7 +84,7 @@ class SmbComWriteAndX extends AndXServerMessageBlock {
 
                writeInt2( fid, dst, dstIndex );
                dstIndex += 2;
-               writeInt4( offset & 0xFFFFFFFFL, dst, dstIndex );
+               writeInt4( offset, dst, dstIndex );
                dstIndex += 4;
                for( int i = 0; i < 4; i++ ) {
                        dst[dstIndex++] = (byte)0x00;
@@ -99,7 +99,7 @@ class SmbComWriteAndX extends AndXServerMessageBlock {
                dstIndex += 2;
                writeInt2( dataOffset, dst, dstIndex );
                dstIndex += 2;
-               writeInt4(( offset >> 32 ) & 0xFFFFFFFFL, dst, dstIndex );
+               writeInt4( offset >> 32, dst, dstIndex );
                dstIndex += 4;
 
                return dstIndex - start;
index 8b75348..6e64a5c 100644 (file)
@@ -705,6 +705,7 @@ synchronized( snd_buf ) {
                                        }
                                        out.write(snd_buf, 0, length);
                                        out.flush();
+//Log.printHexDump( System.err, Thread.currentThread().getName() + ": " + request.toString(), snd_buf, 0, Math.min( length, 63 ));
 
                                        Log.printMessageData( "smb sent", request );
                                        ServerMessageBlock smb = request;
index 6dddf84..ff0975a 100644 (file)
@@ -59,14 +59,14 @@ class Trans2SetFileInformation extends SmbComTransaction {
                int start = dstIndex;
 
                writeTime( createTime, dst, dstIndex ); dstIndex += 8;
-               writeLong( 0L, dst, dstIndex ); dstIndex += 8;
+               writeInt8( 0L, dst, dstIndex ); dstIndex += 8;
                writeTime( lastWriteTime, dst, dstIndex ); dstIndex += 8;
-               writeLong( 0L, dst, dstIndex ); dstIndex += 8;
+               writeInt8( 0L, dst, dstIndex ); dstIndex += 8;
 /* Samba 2.2.7 needs ATTR_NORMAL
  */
                writeInt2( 0x80 | attributes, dst, dstIndex ); dstIndex += 2; 
                                                                                /* 6 zeros observed with NT */
-               writeLong( 0L, dst, dstIndex ); dstIndex += 6;
+               writeInt8( 0L, dst, dstIndex ); dstIndex += 6;
 
                                /* Also observed 4 byte alignment but we stick
                                 * with the default for jCIFS which is 2 */
index c672bce..4db4ac2 100644 (file)
@@ -301,6 +301,10 @@ public class Log {
        public static void printHexDump( String desc, byte[] src ) {
                printHexDump( desc, src, 0, src.length );
        }
+    public static void printHexDump( PrintStream ps, String desc, byte[] src, int srcIndex, int length ) {
+        ps.println( desc );
+               printHexDump( ps, src, srcIndex, length );
+       }
     public static void printHexDump( PrintStream ps, byte[] src, int srcIndex, int length ) {
         int s = length % 16;
         int r = ( s == 0 ) ? length / 16 : length / 16 + 1;