🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.debian.bugs.dist
Article #3332

Bug#1153102: nexus: C++ binding overflows name buffers with HDF4 4.4.0

#3332
From: Sebastien Bacher
Date: Thu, 05 Nov 2026 12:40
112 lines
5721 bytes
This is a multi-part MIME message sent by reportbug.


--===============5902048376930554292==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Source: nexus
Version: 4.4.3-11build1
Severity: important
Tags: patch
X-Debbugs-Cc: seb128@ubuntu.com
User: ubuntu-devel@lists.ubuntu.com
Usertags: origin-ubuntu tenacious ubuntu-patch

Hi,

Thanks for the HDF4 4.4.0 fixes in -12 and -13. The C++ binding has the
same buffer size mismatch that 0008-Fix-HDF4-test-buffer-size-mismatch.patch
fixed in test/napi_test.c, but in the library itself this time.

File::getNextEntry() and File::getNextAttr() in bindings/cpp/NeXusFile.cpp
declare their name/class buffers as char[NX_MAXNAMELEN] (64) and pass
them to NXgetnextentry()/NXgetnextattra(), which take NXname (char[128]).
The HDF4 backend calls Vgetname() with sizeof(NXname) as the buffer size
and HDF4 4.4.0 NUL-pads the whole buffer, so 64 bytes past the end of the
stack buffer get overwritten.

In Debian the build happens to pass, but in Ubuntu, which builds with
GCC 15 and -D_FORTIFY_SOURCE=3, 4.4.3-13 fails to build on amd64, arm64,
ppc64el and s390x:

  8: Number of group attributes: 2
  8:    hugo = namenlos
  8:    cucumber = passion
  8: *** stack smashing detected ***: terminated
   8/10 Test  #8: NAPI-C++-HDF4-test ...............Subprocess aborted

Since this is in libnexus1, any program using the C++ API to list the
entries of an HDF4 file is affected, not only the test.

The attached patch switches those three buffers to NXname. We're
carrying it in Ubuntu as 4.4.3-13ubuntu1.

Cheers,
Sebastien


-- System Information:
Debian Release: forky/sid
  APT prefers resolute-updates
  APT policy: (500, 'resolute-updates'), (500, 'resolute-security'), (500, 'resolute'), (100, 'resolute-backports')
Architecture: amd64 (x86_64)

Kernel: Linux 7.0.0-42-generic (SMP w/16 CPU threads; PREEMPT)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_WARN, TAINT_OOT_MODULE
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

--===============5902048376930554292==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="0009-Fix-CXX-binding-name-buffer-size.patch"

From: Sebastien Bacher <seb128@ubuntu.com>
Date: Wed, 4 Nov 2026 10:00:00 +0100
Subject: Fix C++ binding name buffer size

The NeXus C API takes NXname (char[128]) buffers for names and classes,
and the HDF4 backend passes sizeof(NXname) as the buffer size to
Vgetname()/Vgetclass(). File::getNextEntry() and File::getNextAttr() in
the C++ binding declared those buffers as char[NX_MAXNAMELEN] (64).
HDF4 4.4.0 NUL-pads the whole buffer, so the write spills over the
stack. This is the same mismatch as the one fixed in test/napi_test.c,
and makes NAPI-C++-HDF4-test abort with "stack smashing detected"
depending on compiler and architecture (e.g. GCC 15 with
_FORTIFY_SOURCE=3 on amd64, arm64, ppc64el and s390x).

---
 bindings/cpp/NeXusFile.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/bindings/cpp/NeXusFile.cpp b/bindings/cpp/NeXusFile.cpp
--- a/bindings/cpp/NeXusFile.cpp
+++ b/bindings/cpp/NeXusFile.cpp
@@ -1025,8 +1025,8 @@ Info File::getInfo() {
 
 pair<string, string> File::getNextEntry() {
   // set up temporary variables to get the information
-  char name[NX_MAXNAMELEN];
-  char class_name[NX_MAXNAMELEN];
+  NXname name;
+  NXname class_name;
   int datatype;
 
   NXstatus status = NXgetnextentry(this->m_file_id, name, class_name,
@@ -1099,7 +1099,7 @@ void File::getSlab(void* data, const vec
 
 AttrInfo File::getNextAttr() {
   //string & name, int & length, NXnumtype type) {
-  char name[NX_MAXNAMELEN];
+  NXname name;
   int type;
 
   int rank;

--===============5902048376930554292==--
Technical Details
Message-ID: <NW4V3-9Zr5-1@gated-at.bofh.it>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!fu-berlin.de!bofh.it!news.nic.it!robomod

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!fu-berlin.de!bofh.it!news.nic.it!robomod
From: Sebastien Bacher <seb128@ubuntu.com>
Newsgroups: linux.debian.bugs.dist
Subject: Bug#1153102: nexus: C++ binding overflows name buffers with HDF4 4.4.0
Date: Thu, 05 Nov 2026 13:40:01 +0100
Message-ID: <NW4V3-9Zr5-1@gated-at.bofh.it>
X-Original-To: Debian Bug Tracking System <submit@bugs.debian.org>
X-Mailbox-Line: From debian-bugs-dist-request@lists.debian.org  Thu Nov  5 12:37:13 2026
Old-Return-Path: <debbugs@buxtehude.debian.org>
X-Spam-Flag: NO
X-Spam-Score: -1.65
Reply-To: Sebastien Bacher <seb128@ubuntu.com>, 1153102@bugs.debian.org
Resent-To: debian-bugs-dist@lists.debian.org
Resent-Cc: seb128@ubuntu.com, debian-science-maintainers@lists.alioth.debian.org
X-Debian-Pr-Message: report 1153102
X-Debian-Pr-Package: src:nexus
X-Debian-Pr-Keywords: patch
X-Debian-Pr-Source: nexus
Content-Type: multipart/mixed; boundary="===============5902048376930554292=="
MIME-Version: 1.0
X-Mailer: reportbug 13.2.0+ubuntu1
X-Debian-Message: from BTS
X-Mailing-List: <debian-bugs-dist@lists.debian.org> archive/latest/2000793
List-ID: <debian-bugs-dist.lists.debian.org>
List-URL: <https://lists.debian.org/debian-bugs-dist/>
Approved: robomod@news.nic.it
Lines: 112
Organization: linux.* mail to news gateway
Sender: robomod@news.nic.it
X-Original-Date: Thu, 05 Nov 2026 13:35:38 +0100
X-Original-Message-ID: <179388213870.233515.17519096056279911588.reportbug@seb128-ThinkPad-T16>