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

Package:
src:nexus
Source:
src:nexus
Submitter:
Sebastien Bacher
Date:
2026-11-05 12:37:02 UTC
Severity:
normal
Tags:
#1153102#5
Date:
2026-11-05 12:35:38 UTC
From:
To:
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