cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject cxf git commit: Fixing some potential Null dereferences in the codebase
Date Wed, 13 Apr 2016 18:45:38 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.1.x-fixes b6dca9325 -> 4a749e745


Fixing some potential Null dereferences in the codebase


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/4a749e74
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/4a749e74
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/4a749e74

Branch: refs/heads/3.1.x-fixes
Commit: 4a749e745ee64b3d9ee09eb9e7a35039127d6f40
Parents: b6dca93
Author: Colm O hEigeartaigh <coheigea@apache.org>
Authored: Wed Apr 13 12:23:39 2016 +0100
Committer: Colm O hEigeartaigh <coheigea@apache.org>
Committed: Wed Apr 13 17:12:34 2016 +0100

----------------------------------------------------------------------
 .../org/apache/cxf/common/jaxb/JAXBUtils.java   |  6 ++++-
 .../cxf/interceptor/FaultOutInterceptor.java    |  5 ++--
 .../cxf/xmlbeans/XmlBeansWrapperHelper.java     |  6 +++--
 .../interceptors/WrapperClassInInterceptor.java |  8 ++-----
 .../apache/cxf/transport/jms/util/JMSUtil.java  |  4 +++-
 .../ws/addressing/impl/MAPAggregatorTest.java   |  2 +-
 .../cxf/ws/rm/RMCaptureOutInterceptor.java      |  5 ++--
 .../systest/sts/issueunit/IssueUnitTest.java    |  8 +++----
 .../apache/cxf/systest/jaxrs/JMSBookStore.java  |  6 +++--
 .../cxf/systest/jaxrs/jms/JAXRSJmsTest.java     | 24 +++++++++++++-------
 .../processors/idl/ConstrTypeSpecVisitor.java   |  8 ++++---
 .../processor/internal/ParameterProcessor.java  |  4 ++--
 .../processor/internal/ServiceProcessor.java    |  5 ++++
 .../tools/wsdlto/jaxws/JAXWSContainerTest.java  |  1 +
 14 files changed, 57 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/4a749e74/core/src/main/java/org/apache/cxf/common/jaxb/JAXBUtils.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/common/jaxb/JAXBUtils.java b/core/src/main/java/org/apache/cxf/common/jaxb/JAXBUtils.java
index f8a21d0..9ff8800 100644
--- a/core/src/main/java/org/apache/cxf/common/jaxb/JAXBUtils.java
+++ b/core/src/main/java/org/apache/cxf/common/jaxb/JAXBUtils.java
@@ -676,7 +676,11 @@ public final class JAXBUtils {
                     
                 }
             }
-            
+
+            if (ctx == null) {
+                throw new JAXBException("No ctx found");
+            }
+                
             Object bridge = ctx.getClass().getMethod("createBridge", refClass).invoke(ctx,
ref);
             return ReflectionInvokationHandler.createProxyWrapper(bridge,
                                                                   BridgeWrapper.class);

http://git-wip-us.apache.org/repos/asf/cxf/blob/4a749e74/core/src/main/java/org/apache/cxf/interceptor/FaultOutInterceptor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/interceptor/FaultOutInterceptor.java b/core/src/main/java/org/apache/cxf/interceptor/FaultOutInterceptor.java
index 22bf984..2a9cf80 100644
--- a/core/src/main/java/org/apache/cxf/interceptor/FaultOutInterceptor.java
+++ b/core/src/main/java/org/apache/cxf/interceptor/FaultOutInterceptor.java
@@ -157,11 +157,10 @@ public class FaultOutInterceptor extends AbstractPhaseInterceptor<Message>
{
 
             FaultInfo faultInfo = bfi.getFaultInfo();
             Class<?> c = (Class<?>)faultInfo.getProperty(Class.class.getName());
-            if (c != null && c.isAssignableFrom(class1)
-                && (selectedFaultInfo == null || selectedFaultInfoClass.isAssignableFrom(c)))
{
+            if (c != null && c.isAssignableFrom(class1) && (selectedFaultInfo
== null
+                || (selectedFaultInfoClass != null && selectedFaultInfoClass.isAssignableFrom(c))))
{
                 selectedFaultInfo = faultInfo;
                 selectedFaultInfoClass = c;
-
             }
         }
         return selectedFaultInfo;

http://git-wip-us.apache.org/repos/asf/cxf/blob/4a749e74/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansWrapperHelper.java
----------------------------------------------------------------------
diff --git a/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansWrapperHelper.java
b/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansWrapperHelper.java
index 6b41ebe..c98de9b 100644
--- a/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansWrapperHelper.java
+++ b/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansWrapperHelper.java
@@ -56,8 +56,10 @@ public class XmlBeansWrapperHelper extends AbstractWrapperHelper {
                     Method method = c.getMethod("newInstance", NO_CLASSES);
                     obj = method.invoke(null, NO_PARAMS);                    
                 }
-                // create the value object
-                obj = newType.invoke(obj, NO_PARAMS);
+                if (newType != null) {
+                    // create the value object
+                    obj = newType.invoke(obj, NO_PARAMS);
+                }
                 break;
             }
         }

http://git-wip-us.apache.org/repos/asf/cxf/blob/4a749e74/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WrapperClassInInterceptor.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WrapperClassInInterceptor.java
b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WrapperClassInInterceptor.java
index 316cc46..7291478 100644
--- a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WrapperClassInInterceptor.java
+++ b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WrapperClassInInterceptor.java
@@ -107,12 +107,8 @@ public class WrapperClassInInterceptor extends AbstractPhaseInterceptor<Message>
             MessagePartInfo wrapperPart = wrappedMessageInfo.getFirstMessagePart();
             Class<?> wrapperClass = wrapperPart.getTypeClass();
             Object wrappedObject = lst.get(wrapperPart.getIndex());
-            if (wrapperClass != null && !wrapperClass.isInstance(wrappedObject))
{
-                wrappedObject = null;
-                wrapperPart = null;
-                wrapperClass = null;
-            }
-            if (wrapperClass == null || wrappedObject == null) {
+            if (wrapperClass == null || wrappedObject == null
+                || (wrapperClass != null && !wrapperClass.isInstance(wrappedObject)))
{
                 return;
             }
             

http://git-wip-us.apache.org/repos/asf/cxf/blob/4a749e74/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/util/JMSUtil.java
----------------------------------------------------------------------
diff --git a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/util/JMSUtil.java
b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/util/JMSUtil.java
index 634cffa..ecb2b3b 100644
--- a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/util/JMSUtil.java
+++ b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/util/JMSUtil.java
@@ -103,7 +103,9 @@ public final class JMSUtil {
             session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
             return session.createQueue(name);
         } finally {
-            session.close();
+            if (session != null) {
+                session.close();
+            }
         }
     }
     

http://git-wip-us.apache.org/repos/asf/cxf/blob/4a749e74/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/impl/MAPAggregatorTest.java
----------------------------------------------------------------------
diff --git a/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/impl/MAPAggregatorTest.java
b/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/impl/MAPAggregatorTest.java
index 0e9c1d0..4be1fc7 100644
--- a/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/impl/MAPAggregatorTest.java
+++ b/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/impl/MAPAggregatorTest.java
@@ -694,7 +694,7 @@ public class MAPAggregatorTest extends Assert {
         AddressingProperties maps = mapsInContext 
                                         ? new AddressingProperties()
                                         : null;
-        if (zeroLengthAction) {
+        if (zeroLengthAction && maps != null) {
             maps.setAction(ContextUtils.getAttributedURI(""));
         }
         setUpMessageProperty(message,

http://git-wip-us.apache.org/repos/asf/cxf/blob/4a749e74/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMCaptureOutInterceptor.java
----------------------------------------------------------------------
diff --git a/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMCaptureOutInterceptor.java b/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMCaptureOutInterceptor.java
index 298ddcd..6890201 100644
--- a/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMCaptureOutInterceptor.java
+++ b/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMCaptureOutInterceptor.java
@@ -181,8 +181,9 @@ public class RMCaptureOutInterceptor extends AbstractRMInterceptor<Message>
 {
             maps.getAction().setValue(constants.getCreateSequenceResponseAction());
         } else if (isPartialResponse && action == null
             && isResponseToAction(msg, constants.getSequenceAckAction())) {
-            Collection<SequenceAcknowledgement> acks = rmpsIn.getAcks();
-            if (acks.size() == 1) {
+            Collection<SequenceAcknowledgement> acks =
+                rmpsIn != null ? rmpsIn.getAcks() : null;
+            if (acks != null && acks.size() == 1) {
                 SourceSequence ss = source.getSequence(acks.iterator().next().getIdentifier());
                 if (ss != null && ss.allAcknowledged()) {
                     setAction(maps, constants.getTerminateSequenceAction());

http://git-wip-us.apache.org/repos/asf/cxf/blob/4a749e74/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/issueunit/IssueUnitTest.java
----------------------------------------------------------------------
diff --git a/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/issueunit/IssueUnitTest.java
b/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/issueunit/IssueUnitTest.java
index 1b27208..8eb80e3 100644
--- a/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/issueunit/IssueUnitTest.java
+++ b/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/issueunit/IssueUnitTest.java
@@ -250,7 +250,7 @@ public class IssueUnitTest extends AbstractBusClientServerTestBase {
         if (methods != null && methods.size() > 0) {
             confirmMethod = methods.get(0);
         }
-        assertTrue(confirmMethod.contains("bearer"));
+        assertTrue(confirmMethod != null && confirmMethod.contains("bearer"));
         
         bus.shutdown(true);
     }
@@ -349,7 +349,7 @@ public class IssueUnitTest extends AbstractBusClientServerTestBase {
         if (methods != null && methods.size() > 0) {
             confirmMethod = methods.get(0);
         }
-        assertTrue(confirmMethod.contains("bearer"));
+        assertTrue(confirmMethod != null && confirmMethod.contains("bearer"));
         
         bus.shutdown(true);
     }
@@ -386,7 +386,7 @@ public class IssueUnitTest extends AbstractBusClientServerTestBase {
         if (methods != null && methods.size() > 0) {
             confirmMethod = methods.get(0);
         }
-        assertTrue(confirmMethod.contains("bearer"));
+        assertTrue(confirmMethod != null && confirmMethod.contains("bearer"));
         
         bus.shutdown(true);
     }
@@ -453,7 +453,7 @@ public class IssueUnitTest extends AbstractBusClientServerTestBase {
         if (methods != null && methods.size() > 0) {
             confirmMethod = methods.get(0);
         }
-        assertTrue(confirmMethod.contains("bearer"));
+        assertTrue(confirmMethod != null && confirmMethod.contains("bearer"));
         
         assertTrue("b-issuer".equals(assertion.getIssuerString()));
         String subjectName = assertion.getSaml2().getSubject().getNameID().getValue();

http://git-wip-us.apache.org/repos/asf/cxf/blob/4a749e74/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JMSBookStore.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JMSBookStore.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JMSBookStore.java
index db0b43c..5b3c72e 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JMSBookStore.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JMSBookStore.java
@@ -140,8 +140,10 @@ public class JMSBookStore {
             session.close();
         } finally {
             try {
-                connection.stop();
-                connection.close();
+                if (connection != null) {
+                    connection.stop();
+                    connection.close();
+                }
             } catch (JMSException ex) {
                 // ignore
             }

http://git-wip-us.apache.org/repos/asf/cxf/blob/4a749e74/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/jms/JAXRSJmsTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/jms/JAXRSJmsTest.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/jms/JAXRSJmsTest.java
index b7e6a21..4cf23e4 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/jms/JAXRSJmsTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/jms/JAXRSJmsTest.java
@@ -125,8 +125,10 @@ public class JAXRSJmsTest extends AbstractBusClientServerTestBase {
             session.close();
         } finally {
             try {
-                connection.stop();
-                connection.close();
+                if (connection != null) {
+                    connection.stop();
+                    connection.close();
+                }
             } catch (JMSException ex) {
                 // ignore
             }
@@ -214,8 +216,10 @@ public class JAXRSJmsTest extends AbstractBusClientServerTestBase {
             session.close();
         } finally {
             try {
-                connection.stop();
-                connection.close();
+                if (connection != null) {
+                    connection.stop();
+                    connection.close();
+                }
             } catch (JMSException ex) {
                 // ignore
             }
@@ -242,8 +246,10 @@ public class JAXRSJmsTest extends AbstractBusClientServerTestBase {
             session.close();
         } finally {
             try {
-                connection.stop();
-                connection.close();
+                if (connection != null) {
+                    connection.stop();
+                    connection.close();
+                }
             } catch (JMSException ex) {
                 // ignore
             }
@@ -269,8 +275,10 @@ public class JAXRSJmsTest extends AbstractBusClientServerTestBase {
             session.close();
         } finally {
             try {
-                connection.stop();
-                connection.close();
+                if (connection != null) {
+                    connection.stop();
+                    connection.close();
+                }
             } catch (JMSException ex) {
                 // ignore
             }

http://git-wip-us.apache.org/repos/asf/cxf/blob/4a749e74/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/ConstrTypeSpecVisitor.java
----------------------------------------------------------------------
diff --git a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/ConstrTypeSpecVisitor.java
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/ConstrTypeSpecVisitor.java
index 2e4533c..cd12ffc 100644
--- a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/ConstrTypeSpecVisitor.java
+++ b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/ConstrTypeSpecVisitor.java
@@ -63,10 +63,12 @@ public class ConstrTypeSpecVisitor extends VisitorBase {
             visitor = new EnumVisitor(getScope(), definition, schema, wsdlVisitor);
         }
 
-        visitor.visit(node);
+        if (visitor != null) {
+            visitor.visit(node);
         
-        setSchemaType(visitor.getSchemaType());
-        setCorbaType(visitor.getCorbaType());
+            setSchemaType(visitor.getSchemaType());
+            setCorbaType(visitor.getCorbaType());
+        }
     }
     
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/4a749e74/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ParameterProcessor.java
----------------------------------------------------------------------
diff --git a/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ParameterProcessor.java
b/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ParameterProcessor.java
index 6978740..cd5943f 100644
--- a/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ParameterProcessor.java
+++ b/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ParameterProcessor.java
@@ -423,7 +423,7 @@ public class ParameterProcessor extends AbstractProcessor {
                     if (!qualified && !isRefElement(outputPart, outElement)) {
                         jp.setTargetNamespace("");
                     }
-                    if (!jpIn.getClassName().equals(jp.getClassName())) {
+                    if (jpIn != null && !jpIn.getClassName().equals(jp.getClassName()))
{
                         jp.setStyle(JavaType.Style.OUT);
                     } 
                     addParameter(outputPart, method, jp);
@@ -475,7 +475,7 @@ public class ParameterProcessor extends AbstractProcessor {
                         if (!qualified && !isRefElement(outputPart, outElement))
{
                             jp.setTargetNamespace("");
                         }
-                        if (!jpIn.getClassName().equals(jp.getClassName())) {
+                        if (jpIn != null && !jpIn.getClassName().equals(jp.getClassName()))
{
                             jp.setStyle(JavaType.Style.OUT);
                             checkPartName(outputMessage, outElement, jp);
                         }

http://git-wip-us.apache.org/repos/asf/cxf/blob/4a749e74/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ServiceProcessor.java
----------------------------------------------------------------------
diff --git a/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ServiceProcessor.java
b/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ServiceProcessor.java
index e2b7e5b..e0980a0 100644
--- a/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ServiceProcessor.java
+++ b/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ServiceProcessor.java
@@ -345,6 +345,11 @@ public class ServiceProcessor extends AbstractProcessor {
                 jf = jf2;
             }
         }
+
+        if (jf == null) {
+            throw new ToolException("No Java Interface available");
+        }
+
         if (isSoapBinding()) {
             SoapBinding soapBinding = (SoapBinding)bindingObj;
             if (SOAPBindingUtil.getSoapStyle(soapBinding.getStyle()) == null) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/4a749e74/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/JAXWSContainerTest.java
----------------------------------------------------------------------
diff --git a/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/JAXWSContainerTest.java
b/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/JAXWSContainerTest.java
index e66cd8a..f99416b 100644
--- a/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/JAXWSContainerTest.java
+++ b/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/JAXWSContainerTest.java
@@ -188,6 +188,7 @@ public class JAXWSContainerTest extends ProcessorTestBase {
                 }
             }
             assertTrue(methodSame);
+            assertNotNull(m1);
             
             assertEquals(2, m1.getExceptions().size());
             List<String> names = new ArrayList<String>();


Mime
View raw message