[omniORB] G++ 12.2 complains with stringop-overflow warning

Thomas Braun thomas.braun at byte-physics.de
Thu Jun 1 17:59:44 UTC 2023


Hello,

one of the newer gcc versions complains about some omniORB code.
I'm attaching the files needed for reproduction.

Versions:
- OS: Debian unstable from today
- Compiler: g++ (Debian 12.2.0-14) 12.2.0
- omniORB: 4.2.5+ds1-1.1+b1

When compiling with 
 g++ -O3 -DNDEBUG -fstack-protector-strong -Werror  \
   -I /usr/include/omniORB4 test.cpp

I get the following warning

In file included from /usr/include/omniORB4/omniInternal.h:44,
                 from /usr/include/omniORB4/CORBA.h:63,
                 from test.cpp:1:
In member function ‘void _CORBA_Sequence<T>::copybuffer(_CORBA_ULong)
[with T = unsigned char]’,
    inlined from ‘void _CORBA_Sequence<T>::length(_CORBA_ULong) [with T
= unsigned char]’ at /usr/include/omniORB4/seqTemplatedecls.h:59:12,
    inlined from ‘int main(int, char**)’ at test.cpp:8:10:
/usr/include/omniORB4/seqTemplatedecls.h:211:17: error: writing 8 bytes
into a region of size 1 [-Werror=stringop-overflow=]
  211 |       newbuf[i] = pd_buf[i];
      |       ~~~~~~~~~~^~~~~~~~~
In static member function ‘static T*
_CORBA_Sequence<T>::allocbuf(_CORBA_ULong) [with T = unsigned char]’,
    inlined from ‘void _CORBA_Sequence<T>::copybuffer(_CORBA_ULong)
[with T = unsigned char]’ at
/usr/include/omniORB4/seqTemplatedecls.h:205:25,
    inlined from ‘void _CORBA_Sequence<T>::length(_CORBA_ULong) [with T
= unsigned char]’ at /usr/include/omniORB4/seqTemplatedecls.h:59:12,
    inlined from ‘int main(int, char**)’ at test.cpp:8:10:
/usr/include/omniORB4/seqTemplatedecls.h:84:13: note: destination
object of size 1 allocated by ‘operator new []’
   84 |       tmp = new T[nelems];
      |             ^~~~~~~~~~~~~

Now it is easily possible that the compiler is wrong but I would like
be sure before I ignore this warning.

In addition I do see some mixing of unsigned long and _CORBA_ULong in
seqTemplatedecls.h/copybuffer which I find confusing as IIRC you can't
interchangebly use these types in general.

Thanks,
Thomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: stringop-overflow-repro.tar.gz
Type: application/x-compressed-tar
Size: 54484 bytes
Desc: not available
URL: <https://www.omniorb-support.com/pipermail/omniorb-list/attachments/20230601/265b62d2/attachment-0001.bin>


More information about the omniORB-list mailing list