JACoders / OpenJK

Community effort to maintain and improve Jedi Academy (SP & MP) + Jedi Outcast (SP only) released by Raven Software
GNU General Public License v2.0
2.03k stars 614 forks source link

Strict aliasing and buffer overflow #835

Closed susnux closed 8 years ago

susnux commented 8 years ago

When compiling on openSUSE I get this errors:

[  558s] I: Program is likely to break with new gcc. Try -fno-strict-aliasing.
[  558s] W: OpenJK strict-aliasing-punning /home/abuild/rpmbuild/BUILD/OpenJK-1463085567.ba25e50/codemp/qcommon/net_ip.cpp:181, 189, 333, 334, 618, 619, 646, 647
[  558s] 
[  558s] I: Statement is overflowing a buffer
[  558s] E: OpenJK bufferoverflow /home/abuild/rpmbuild/BUILD/OpenJK-1463085567.ba25e50/codemp/qcommon/GenericParser2.cpp:161:34

I have no idea what the strict aliasing warning mean in that cases. But I think the buffer overflow is because in that line length is never checked if length == 0 because in that case length would be set to 0xFFFFFFFF and the memmove would segfault. So for me I fixed that by simply add length > 0 && to the if statement.

Some other minor warnings are:

[  175s] OpenJK.x86_64: I: binary-or-shlib-calls-gethostbyname /usr/lib/openjk/JediAcademy/openjk.x86_64
[  175s] OpenJK.x86_64: I: binary-or-shlib-calls-gethostbyname /usr/lib/openjk/JediAcademy/openjkded.x86_64
[  175s] The binary calls gethostbyname(). Please port the code to use getaddrinfo().

(gethostbyname() is deprecated)

aufau commented 8 years ago

I'll just leave it here for now: https://github.com/mvdevs/jk2mv/commit/495f55fb2650a733e841fc4392a7645d9d2fcc88

Razish commented 8 years ago

Fixed strict aliasing warnings in 2764ebc from the above commit

xycaleth commented 8 years ago

Looks like this is fixed...