This is an automated email from the ASF dual-hosted git repository.
markt-asf pushed a commit to branch 1.3.x
in repository https://gitbox.apache.org/repos/asf/tomcat-native.git
The following commit(s) were added to refs/heads/1.3.x by this push:
new 511335ff8 Harden against mis-use
511335ff8 is described below
commit 511335ff8fea8cb6d17e28623df51c92a1851fb8
Author: Mark Thomas <[email protected]>
AuthorDate: Fri Aug 28 18:49:45 2026 +0100
Harden against mis-use
---
native/src/bb.c | 13 ++++++++++++-
xdocs/miscellaneous/changelog.xml | 4 ++++
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/native/src/bb.c b/native/src/bb.c
index 616ea78c7..d0292f0e3 100644
--- a/native/src/bb.c
+++ b/native/src/bb.c
@@ -118,8 +118,19 @@ TCN_IMPLEMENT_CALL(void, Buffer, free)(TCN_STDARGS,
jobject bb)
TCN_IMPLEMENT_CALL(jlong, Buffer, address)(TCN_STDARGS, jobject bb)
{
+ void *address;
+
UNREFERENCED(o);
- return P2J((*e)->GetDirectBufferAddress(e, bb));
+ address = (*e)->GetDirectBufferAddress(e, bb);
+ if (address == NULL) {
+ jclass npe = (*e)->FindClass(e, "java/lang/NullPointerException");
+ if (npe != NULL) {
+ (*e)->ThrowNew(e, npe, "ByteBuffer is null or not direct");
+ (*e)->DeleteLocalRef(e, npe);
+ }
+ return 0;
+ }
+ return P2J(address);
}
TCN_IMPLEMENT_CALL(jlong, Buffer, size)(TCN_STDARGS, jobject bb)
diff --git a/xdocs/miscellaneous/changelog.xml
b/xdocs/miscellaneous/changelog.xml
index 5ae740bc6..50c523261 100644
--- a/xdocs/miscellaneous/changelog.xml
+++ b/xdocs/miscellaneous/changelog.xml
@@ -78,6 +78,10 @@
<fix>
Stricter OCSP handling when soft-fail is disabled. (markt)
</fix>
+ <fix>
+ Harden against the mis-use of <code>Buffer.address(ByteBuffer)</code>.
+ (markt)
+ </fix>
</changelog>
</section>
<section name="1.3.8" rtext="2026-06-15">
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]