tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jfcl...@apache.org
Subject svn commit: r1690279 - /tomcat/native/trunk/native/src/network.c
Date Fri, 10 Jul 2015 15:48:02 GMT
Author: jfclere
Date: Fri Jul 10 15:48:01 2015
New Revision: 1690279

URL: http://svn.apache.org/r1690279
Log:
Make sure we don't core the JVM if called wrongly from a destroyed or closed socket.

Modified:
    tomcat/native/trunk/native/src/network.c

Modified: tomcat/native/trunk/native/src/network.c
URL: http://svn.apache.org/viewvc/tomcat/native/trunk/native/src/network.c?rev=1690279&r1=1690278&r2=1690279&view=diff
==============================================================================
--- tomcat/native/trunk/native/src/network.c (original)
+++ tomcat/native/trunk/native/src/network.c Fri Jul 10 15:48:01 2015
@@ -1152,8 +1152,10 @@ TCN_IMPLEMENT_CALL(jint, Socket, optSet)
     if (!s->sock) {
         return APR_ENOTSOCK;
     }
-    else
-        return (jint)(*s->net->opt_set)(s->opaque, (apr_int32_t)opt, (apr_int32_t)on);
+    if(!s->net) {
+        return -(jint)APR_EINVALSOCK;
+    }
+    return (jint)(*s->net->opt_set)(s->opaque, (apr_int32_t)opt, (apr_int32_t)on);
 }
 
 TCN_IMPLEMENT_CALL(jint, Socket, optGet)(TCN_STDARGS, jlong sock,
@@ -1163,12 +1165,16 @@ TCN_IMPLEMENT_CALL(jint, Socket, optGet)
     apr_int32_t on = 0;
 
     UNREFERENCED(o);
-    if (!s->sock)
+    if (!s->sock) {
         tcn_ThrowAPRException(e, APR_ENOTSOCK);
-    else {
-        TCN_THROW_IF_ERR((*s->net->opt_get)(s->opaque, (apr_int32_t)opt,
-                                            &on), on);
+        return APR_ENOTSOCK;
+    }
+    if(!s->net) {
+        tcn_ThrowAPRException(e, APR_EINVALSOCK);
+        return -(jint)APR_EINVALSOCK;
     }
+    TCN_THROW_IF_ERR((*s->net->opt_get)(s->opaque, (apr_int32_t)opt,
+                                        &on), on);
 cleanup:
     return (jint)on;
 }
@@ -1181,9 +1187,11 @@ TCN_IMPLEMENT_CALL(jint, Socket, timeout
     UNREFERENCED(o);
     TCN_ASSERT(s->opaque != NULL);
     if (!sock) {
-        tcn_ThrowAPRException(e, APR_ENOTSOCK);
         return APR_ENOTSOCK;
     }
+    if(!s->net) {
+        return -(jint)APR_EINVALSOCK;
+    }
     return (jint)(*s->net->timeout_set)(s->opaque, J2T(timeout));
 }
 
@@ -1197,6 +1205,10 @@ TCN_IMPLEMENT_CALL(jlong, Socket, timeou
         tcn_ThrowAPRException(e, APR_ENOTSOCK);
         return 0;
     }
+    if(!s->net) {
+        tcn_ThrowAPRException(e, APR_EINVALSOCK);
+        return -(jint)APR_EINVALSOCK;
+    }
     TCN_ASSERT(s->opaque != NULL);
 
     TCN_THROW_IF_ERR((*s->net->timeout_get)(s->opaque, &timeout), timeout);



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message