From: Felix Schumacher Date: Sat, 1 Nov 2014 11:17:18 +0000 (+0100) Subject: jcifs-1.3.18 from tgz X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;ds=inline;p=jcifs_without_docs.git jcifs-1.3.18 from tgz Wed Oct 29 21:08:01 EDT 2014 jcifs-1.3.18 This release includes mostly minor fixes including: System.getProperties().clone() modified to prevent ConcurrentModificationException when loading classes. A logical check has been added to prevent a NullPointerException. Reset tree if transport disconnected. DCERPC error message improved. Note: There are several other bugs that have been discussed on the mailing list that have not been fixed in this release. --- diff --git a/README.txt b/README.txt index afaf8c8..bea8533 100644 --- a/README.txt +++ b/README.txt @@ -1,7 +1,15 @@ -Sat Jan 28 13:46:42 EST 2012 -jcifs-1.3.18b +Wed Oct 29 21:08:01 EDT 2014 +jcifs-1.3.18 +This release includes mostly minor fixes including: +System.getProperties().clone() modified to prevent +ConcurrentModificationException when loading classes. A logical check has been added to prevent a NullPointerException. +Reset tree if transport disconnected. +DCERPC error message improved. + +Note: There are several other bugs that have been discussed on the +mailing list that have not been fixed in this release. Tue Oct 18 15:10:23 EDT 2011 jcifs-1.3.17 diff --git a/build.xml b/build.xml index 6126322..05b221d 100644 --- a/build.xml +++ b/build.xml @@ -1,7 +1,7 @@ - - + + diff --git a/examples/10883563.doc b/examples/10883563.doc index c67d428..62644d9 100644 --- a/examples/10883563.doc +++ b/examples/10883563.doc @@ -1,6 +1,6 @@ -C:\tmp>ktpass /princ HTTP/www.foo.net@WIN.NET /ptype KRB5_NT_PRINCIPAL /desonly /pass asj7j112233hh4455 /mapuser test2 -Targeting domain controller: ts0.win.net -Using legacy password setting method -Successfully mapped HTTP/www.foo.net to test2. -Key created. +C:\tmp>ktpass /princ HTTP/www.foo.net@WIN.NET /ptype KRB5_NT_PRINCIPAL /desonly /pass asj7j112233hh4455 /mapuser test2 +Targeting domain controller: ts0.win.net +Using legacy password setting method +Successfully mapped HTTP/www.foo.net to test2. +Key created. Account test2 has been set for DES-only encryption. \ No newline at end of file diff --git a/examples/ClassLoaderTest.java b/examples/ClassLoaderTest.java new file mode 100644 index 0000000..9894d07 --- /dev/null +++ b/examples/ClassLoaderTest.java @@ -0,0 +1,72 @@ +import java.net.URL; +import java.net.URLClassLoader; +import java.lang.reflect.Method; +import java.io.PrintStream; +import java.io.InputStream; + +import jcifs.Config; + +/* +This test was used to provoke the following exception: + +Exception in thread "main" .java.lang.ExceptionInInitializerError + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) + at java.lang.reflect.Method.invoke(Method.java:592) + at ClassLoaderTest.main(ClassLoaderTest.java:46) +Caused by: java.util.ConcurrentModificationException + at java.util.Hashtable$Enumerator.next(Hashtable.java:1020) + at java.util.Hashtable.putAll(Hashtable.java:469) + at jcifs.Config.load(Config.java:164) + at jcifs.Config.(Config.java:70) + +caused by this line of code in the jcifs.Config static initializer: + + prp.putAll( System.getProperties() ); + +The fix is to simply clone() the system properties like: + + prp.putAll( (java.util.Map)System.getProperties().clone() ); + +At least this removes the error. +*/ + +public class ClassLoaderTest implements Runnable { + + static final int MULT = 1; + + public void run() + { + for (int i = 0; i < (ClassLoaderTest.MULT * 700); i++) { + System.setProperty("i" + i, "x"); + System.err.print('.'); + } + } + + public static void main(String[] argv) throws Exception + { + if (argv.length < 1) { + System.err.println("usage: ClassLoaderTest "); + System.exit(1); + } + + ClassLoaderTest clt = new ClassLoaderTest(); + (new Thread(clt)).start(); + + for (int j = 0; j < (ClassLoaderTest.MULT * 100); j++) { + URL url = new URL(argv[0]); + URLClassLoader ucl = URLClassLoader.newInstance(new URL[] {url}); + Class c = ucl.loadClass("jcifs.Config"); +/* + Method m = c.getMethod("list", PrintStream.class); + m.invoke(null, new Object[] { System.err }); +*/ + Method m = c.getMethod("load", InputStream.class); + m.invoke(null, new Object[] { null }); + ucl = null; + System.err.print('+'); + } + + } +} diff --git a/examples/TestBase64.java b/examples/TestBase64.java new file mode 100644 index 0000000..7e20add --- /dev/null +++ b/examples/TestBase64.java @@ -0,0 +1,23 @@ +import jcifs.util.Base64; +import jcifs.util.Hexdump; + +public class TestBase64 { + + public void run(String str) throws Exception + { + Base64 b64 = new Base64(); + + byte[] bytes = b64.decode(str); + + Hexdump.hexdump(System.out, bytes, 0, bytes.length); + } + + public static void main(String[] argv) throws Exception { + if (argv.length < 1) { + System.err.println( "usage: TestBase64 " ); + System.exit(1); + } + TestBase64 t = new TestBase64(); + t.run(argv[0]); + } +} diff --git a/examples/run.sh b/examples/run.sh new file mode 100644 index 0000000..47303f1 --- /dev/null +++ b/examples/run.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +JAVA_HOME=/usr/local/java5 +CLASSPATH=../build:. +RUN="${JAVA_HOME}/bin/java -cp ${CLASSPATH}" + +$RUN ClassLoaderTest file:/home/miallen/p/jcifs/jcifs-1.3.18.jar diff --git a/examples/runtests.sh b/examples/runtests.sh index e643db2..ebb86e6 100644 --- a/examples/runtests.sh +++ b/examples/runtests.sh @@ -2,17 +2,17 @@ JAVA_HOME=/usr/local/java5 CLASSPATH=../build:. -PROPERTIES=../../user2.prp +PROPERTIES=../../bcarter.prp RUN="${JAVA_HOME}/bin/java -cp ${CLASSPATH} -Djcifs.properties=${PROPERTIES}" #SERVER=192.168.15.110 -SERVER=dc1.w.net +SERVER=dc08.busico.local SHARE=tmp DIR=test # Domain-based DFS #SERVER=192.168.15.110 -#SERVER=w.net +#SERVER=busico.local #SHARE=root2 #DIR=test @@ -35,11 +35,11 @@ URL_WRITE_DIR=${URL_SHARE}${WRITE_DIR} set -x -$RUN SidLookup dc1.w.net S-1-5-21-2779991279-2625083122-3494051191-1361 +$RUN SidLookup dc08.busico.local S-1-5-21-2779991279-2625083122-3494051191-1361 $RUN TestGetParent 'smb://' $RUN TestGetParent ${URL_WRITE_DIR} -$RUN TestListLoop 'smb://dc5.w.net/tmp/' 2 -$RUN TestCopy smb://fs1.w.net/tmp/xxx/ smb://dc5.w.net/tmp/deleteme/ +$RUN TestListLoop 'smb://dc08.busico.local/tmp/' 2 +$RUN TestCopy smb://dc08.busico.local/tmp/xxx/ smb://dc08.busico.local/tmp/deleteme/ $RUN ListFiles smb:// $RUN ListFiles smb://192.168.15.110/tmp/ $RUN ListACL ${URL_WRITE_DIR} diff --git a/patches/url_leading_space.patch b/patches/url_leading_space.patch new file mode 100644 index 0000000..1a0e1c9 --- /dev/null +++ b/patches/url_leading_space.patch @@ -0,0 +1,66 @@ +diff --git a/jcifs/jcifs/smb/SmbFile.java b/jcifs/jcifs/smb/SmbFile.java +index 22391e9..00a1da3 100644 +--- a/jcifs/jcifs/smb/SmbFile.java ++++ b/jcifs/jcifs/smb/SmbFile.java +@@ -268,6 +268,7 @@ import java.util.Date; + + public class SmbFile extends URLConnection implements SmbConstants { + ++ static final String RFC_2396_DISTINGUISHING_PREFIX = "URL:"; + static final int O_RDONLY = 0x01; + static final int O_WRONLY = 0x02; + static final int O_RDWR = 0x03; +@@ -465,7 +466,7 @@ public class SmbFile extends URLConnection implements SmbConstants { + throws MalformedURLException, UnknownHostException { + this( context.isWorkgroup0() ? + new URL( null, "smb://" + name, Handler.SMB_HANDLER ) : +- new URL( context.url, name, Handler.SMB_HANDLER ), context.auth ); ++ new URL( context.url, RFC_2396_DISTINGUISHING_PREFIX+name, Handler.SMB_HANDLER ), context.auth ); + } + + /** +@@ -483,7 +484,7 @@ public class SmbFile extends URLConnection implements SmbConstants { + + public SmbFile( String context, String name ) throws MalformedURLException { + this( new URL( new URL( null, context, Handler.SMB_HANDLER ), +- name, Handler.SMB_HANDLER )); ++ RFC_2396_DISTINGUISHING_PREFIX+name, Handler.SMB_HANDLER )); + } + + /** +@@ -536,7 +537,7 @@ public class SmbFile extends URLConnection implements SmbConstants { + */ + public SmbFile( String context, String name, NtlmPasswordAuthentication auth ) + throws MalformedURLException { +- this( new URL( new URL( null, context, Handler.SMB_HANDLER ), name, Handler.SMB_HANDLER ), auth ); ++ this( new URL( new URL( null, context, Handler.SMB_HANDLER ), RFC_2396_DISTINGUISHING_PREFIX+name, Handler.SMB_HANDLER ), auth ); + } + /** + * Constructs an SmbFile representing a resource on an SMB network such +@@ -559,7 +560,7 @@ public class SmbFile extends URLConnection implements SmbConstants { + */ + public SmbFile( String context, String name, NtlmPasswordAuthentication auth, int shareAccess ) + throws MalformedURLException { +- this( new URL( new URL( null, context, Handler.SMB_HANDLER ), name, Handler.SMB_HANDLER ), auth ); ++ this( new URL( new URL( null, context, Handler.SMB_HANDLER ), RFC_2396_DISTINGUISHING_PREFIX + name, Handler.SMB_HANDLER ), auth ); + if ((shareAccess & ~(FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE)) != 0) { + throw new RuntimeException( "Illegal shareAccess parameter" ); + } +@@ -587,7 +588,7 @@ public class SmbFile extends URLConnection implements SmbConstants { + throws MalformedURLException, UnknownHostException { + this( context.isWorkgroup0() ? + new URL( null, "smb://" + name, Handler.SMB_HANDLER ) : +- new URL( context.url, name, Handler.SMB_HANDLER ), context.auth ); ++ new URL( context.url, RFC_2396_DISTINGUISHING_PREFIX + name, Handler.SMB_HANDLER ), context.auth ); + if ((shareAccess & ~(FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE)) != 0) { + throw new RuntimeException( "Illegal shareAccess parameter" ); + } +@@ -621,7 +622,7 @@ public class SmbFile extends URLConnection implements SmbConstants { + throws MalformedURLException, UnknownHostException { + this( context.isWorkgroup0() ? + new URL( null, "smb://" + name + "/", Handler.SMB_HANDLER ) : +- new URL( context.url, name + (( attributes & ATTR_DIRECTORY ) > 0 ? "/" : "" ))); ++ new URL( context.url, RFC_2396_DISTINGUISHING_PREFIX +name + (( attributes & ATTR_DIRECTORY ) > 0 ? "/" : "" ))); + + /* why was this removed before? DFS? copyTo? Am I going around in circles? */ + auth = context.auth; diff --git a/src/jcifs/Config.java b/src/jcifs/Config.java index c00e434..b3a88a4 100644 --- a/src/jcifs/Config.java +++ b/src/jcifs/Config.java @@ -160,7 +160,7 @@ public static int socketCount = 0; prp.load( in ); } try { - prp.putAll( System.getProperties() ); + prp.putAll( (java.util.Map)System.getProperties().clone() ); } catch( SecurityException se ) { if( log.level > 1 ) log.println( "SecurityException: jcifs will ignore System properties" ); diff --git a/src/jcifs/dcerpc/DcerpcBinding.java b/src/jcifs/dcerpc/DcerpcBinding.java index 6388f41..0e9fa7c 100644 --- a/src/jcifs/dcerpc/DcerpcBinding.java +++ b/src/jcifs/dcerpc/DcerpcBinding.java @@ -58,8 +58,8 @@ public class DcerpcBinding { if (key.equals("endpoint")) { endpoint = val.toString(); String lep = endpoint.toLowerCase(); - if (lep.toLowerCase().startsWith("\\pipe\\")) { - String iface = (String)INTERFACES.get(lep.toLowerCase().substring(6)); + if (lep.startsWith("\\pipe\\")) { + String iface = (String)INTERFACES.get(lep.substring(6)); if (iface != null) { int c, p; c = iface.indexOf(':'); diff --git a/src/jcifs/netbios/NameServicePacket.java b/src/jcifs/netbios/NameServicePacket.java index 3107efa..c8ef347 100644 --- a/src/jcifs/netbios/NameServicePacket.java +++ b/src/jcifs/netbios/NameServicePacket.java @@ -222,6 +222,13 @@ abstract class NameServicePacket { addrEntry = new NbtAddress[rDataLength / 6]; end = srcIndex + rDataLength; +/* Apparently readRDataWireFormat can return 0 if resultCode != 0 in +which case this will look indefinitely. Putting this else clause around +the loop might fix that. But I would need to see a capture to confirm. +if (resultCode != 0) { + srcIndex += rDataLength; +} else { +*/ for( addrIndex = 0; srcIndex < end; addrIndex++ ) { srcIndex += readRDataWireFormat( src, srcIndex ); }