GeezerVison is showing github.com — Delete local references as soon as possible in callbacks (#996) · netty/netty-tcnative@990751e
File treeExpand file treeCollapse file tree Open diff view settings openssl-dynamic/src/main/c
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: openssl-dynamic/src/main/c/cert_compress.c +4Lines changed: 4 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -40,6 +40,8 @@ static int compress(jobject compression_algorithm, jmethodID compress_method, SS | 40 | 40 | jbyteArray resultArray = (*e)->CallObjectMethod(e, compression_algorithm, compress_method, | 41 | 41 | P2J(ssl), inputArray); | 42 | 42 |
| | 43 | + NETTY_JNI_UTIL_DELETE_LOCAL(e, inputArray); | | 44 | + | 43 | 45 | if ((*e)->ExceptionCheck(e) != JNI_FALSE) { | 44 | 46 | (*e)->ExceptionClear(e); | 45 | 47 | return 0; // Exception while calling into Java | @@ -88,6 +90,8 @@ static int decompress(jobject compression_algorithm, jmethodID decompress_method | 88 | 90 | jbyteArray resultArray = (*e)->CallObjectMethod(e, compression_algorithm, decompress_method, | 89 | 91 | P2J(ssl), uncompressed_len, inputArray); | 90 | 92 |
| | 93 | + NETTY_JNI_UTIL_DELETE_LOCAL(e, inputArray); | | 94 | + | 91 | 95 | if ((*e)->ExceptionCheck(e) != JNI_FALSE) { | 92 | 96 | (*e)->ExceptionClear(e); | 93 | 97 | return 0; // Exception while calling into Java | |
Collapse file Copy file name to clipboardExpand all lines: openssl-dynamic/src/main/c/sslcontext.c +14Lines changed: 14 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1631,6 +1631,8 @@ static int SSL_cert_verify(X509_STORE_CTX *ctx, void *arg) { | 1631 | 1631 |
| 1632 | 1632 | result = (*e)->CallIntMethod(e, c->verifier, c->verifier_method, P2J(ssl), array, authMethodString); | 1633 | 1633 |
| | 1634 | + NETTY_JNI_UTIL_DELETE_LOCAL(e, authMethodString); | | 1635 | + | 1634 | 1636 | if ((*e)->ExceptionCheck(e)) { | 1635 | 1637 | // We always need to set the error as stated in the SSL_CTX_set_cert_verify_callback manpage, so set the result | 1636 | 1638 | // to the correct value. | @@ -1761,6 +1763,8 @@ enum ssl_verify_result_t tcn_SSL_cert_custom_verify(SSL* ssl, uint8_t *out_alert | 1761 | 1763 | // Execute the java callback | 1762 | 1764 | result = (*e)->CallIntMethod(e, state->ctx->verifier, state->ctx->verifier_method, P2J(ssl), array, authMethodString); | 1763 | 1765 |
| | 1766 | + NETTY_JNI_UTIL_DELETE_LOCAL(e, authMethodString); | | 1767 | + | 1764 | 1768 | if ((*e)->ExceptionCheck(e) == JNI_TRUE) { | 1765 | 1769 | result = X509_V_ERR_UNSPECIFIED; | 1766 | 1770 | goto complete; | @@ -1985,6 +1989,9 @@ static int cert_requested(SSL* ssl, X509** x509Out, EVP_PKEY** pkeyOut) { | 1985 | 1989 | (*e)->CallVoidMethod(e, c->cert_requested_callback, c->cert_requested_callback_method, | 1986 | 1990 | P2J(ssl), P2J(x509Out), P2J(pkeyOut), types, issuers); | 1987 | 1991 |
| | 1992 | + NETTY_JNI_UTIL_DELETE_LOCAL(e, types); | | 1993 | + NETTY_JNI_UTIL_DELETE_LOCAL(e, issuers); | | 1994 | + | 1988 | 1995 | // Check if java threw an exception and if so signal back that we should not continue with the handshake. | 1989 | 1996 | if ((*e)->ExceptionCheck(e)) { | 1990 | 1997 | return -1; | @@ -2113,6 +2120,9 @@ static int certificate_cb(SSL* ssl, void* arg) { | 2113 | 2120 | (*e)->CallVoidMethod(e, state->ctx->certificate_callback, state->ctx->certificate_callback_method, | 2114 | 2121 | P2J(ssl), types, issuers); | 2115 | 2122 |
| | 2123 | + NETTY_JNI_UTIL_DELETE_LOCAL(e, types); | | 2124 | + NETTY_JNI_UTIL_DELETE_LOCAL(e, issuers); | | 2125 | + | 2116 | 2126 | // Check if java threw an exception and if so signal back that we should not continue with the handshake. | 2117 | 2127 | if ((*e)->ExceptionCheck(e) != JNI_TRUE) { | 2118 | 2128 | // Everything good... | @@ -2509,6 +2519,7 @@ static SSL_SESSION* tcn_get_session_cb(SSL *ssl, unsigned char *session_id, int | 2509 | 2519 | (*e)->SetByteArrayRegion(e, bArray, 0, len, (jbyte*) session_id); | 2510 | 2520 |
| 2511 | 2521 | result = (*e)->CallLongMethod(e, c->ssl_session_cache, c->ssl_session_cache_get_method, P2J(ssl), bArray); | | 2522 | + NETTY_JNI_UTIL_DELETE_LOCAL(e, bArray); | 2512 | 2523 |
| 2513 | 2524 | if ((*e)->ExceptionCheck(e)) { | 2514 | 2525 | return NULL; | @@ -2676,6 +2687,9 @@ static void keylog_cb(const SSL* ssl, const char *line) { | 2676 | 2687 | // Execute the java callback | 2677 | 2688 | (*e)->CallVoidMethod(e, state->ctx->keylog_callback, state->ctx->keylog_callback_method, | 2678 | 2689 | P2J(ssl), outputLine); | | 2690 | + | | 2691 | + NETTY_JNI_UTIL_DELETE_LOCAL(e, outputLine); | | 2692 | + | 2679 | 2693 | // Clear the exception if any was thrown as otherwise we might corrupt the JNI state | 2680 | 2694 | if ((*e)->ExceptionCheck(e) == JNI_TRUE) { | 2681 | 2695 | (*e)->ExceptionClear(e); | |
|