apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From minf...@apache.org
Subject svn commit: r597878 - /apr/apr-util/trunk/ssl/apr_ssl_openssl.c
Date Sat, 24 Nov 2007 16:44:58 GMT
Author: minfrin
Date: Sat Nov 24 08:44:58 2007
New Revision: 597878

URL: http://svn.apache.org/viewvc?rev=597878&view=rev
Log:
Ensure alloc's are tested for ENOMEM. Clarify the scope of these tests
by adding missing braces.

Modified:
    apr/apr-util/trunk/ssl/apr_ssl_openssl.c

Modified: apr/apr-util/trunk/ssl/apr_ssl_openssl.c
URL: http://svn.apache.org/viewvc/apr/apr-util/trunk/ssl/apr_ssl_openssl.c?rev=597878&r1=597877&r2=597878&view=diff
==============================================================================
--- apr/apr-util/trunk/ssl/apr_ssl_openssl.c (original)
+++ apr/apr-util/trunk/ssl/apr_ssl_openssl.c Sat Nov 24 08:44:58 2007
@@ -107,11 +107,16 @@
                                                  sizeof(*sslData));
     apr_os_sock_t fd;
 
-    if (!sslData || !asf->sslData)
+    if (!sslData) {
+        return APR_ENOMEM;
+    }
+    if (!sslData || !asf->sslData) {
         return APR_EINVAL;
+    }
     sslData->ssl = SSL_new(asf->sslData->ctx);
-    if (!sslData->ssl)
+    if (!sslData->ssl) {
         return APR_EINVALSOCK; /* Hmm, better error code? */
+    }
 
     /* Joe Orton points out this is actually wrong and assumes that
      * that we're on an "fd" system. We need some better way of handling
@@ -196,15 +201,21 @@
     apr_os_sock_t fd;
     int sslOp;
 
-    if (!sslData || !oldSock->factory)
+    if (!sslData) {
+        return APR_ENOMEM;
+    }
+    if (!oldSock->factory) {
         return APR_EINVAL;
+    }
 
     sslData->ssl = SSL_new(oldSock->factory->sslData->ctx);
-    if (!sslData->ssl)
+    if (!sslData->ssl) {
         return APR_EINVAL;
+    }
 
-    if (apr_os_sock_get(&fd, newSock->plain) != APR_SUCCESS)
+    if (apr_os_sock_get(&fd, newSock->plain) != APR_SUCCESS) {
         return APR_EINVALSOCK;
+    }
     SSL_set_fd(sslData->ssl, fd);
 
     newSock->pool = pool;
@@ -369,6 +380,9 @@
 
     if (!*e) {
         *e = (apr_evp_crypt_t *)apr_pcalloc(p, sizeof(apr_evp_crypt_t));
+    }
+    if (!*e) {
+        return APR_ENOMEM;
     }
     (*e)->pool = p;
     (*e)->purpose = f->purpose;



Mime
View raw message