FS#75031 - [zsnes] buffer overflow when starting zsnes

Attached to Project: Community Packages
Opened by Alexander F. Rødseth (xyproto) - Saturday, 11 June 2022, 08:09 GMT
Last edited by Antonio Rojas (arojas) - Monday, 04 July 2022, 16:33 GMT
Task Type Bug Report
Category Packages: Multilib
Status Closed
Assigned To Alexander F. Rødseth (xyproto)
Antonio Rojas (arojas)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:

@Proscritt09 on GitHub created an issue reporting that after the zsnes package changed from pkgrel=1 to pkgrel=2, an issue appeared, when running the ActRaiser game:

*** buffer overflow detected ***: terminated
Aborted (core dumped)

The only changes from pkgrel=1 to pkgrel=2 in the PKGBUILD are:

export CFLAGS=${CFLAGS/-fcf-protection/}
export CXXFLAGS=${CXXFLAGS/-fcf-protection/}

zsnes 2.0.9-2

@Proscritt09 is using the 5.18.3-arch1-1 kernel (on EndeavourOS, but I think the issue might be related to the new CFLAGS/CXXFLAGS).
This task depends upon

Closed by  Antonio Rojas (arojas)
Monday, 04 July 2022, 16:33 GMT
Reason for closing:  Fixed
Additional comments about closing:  zsnes 2.0.10-1
Comment by Antonio Rojas (arojas) - Saturday, 11 June 2022, 08:26 GMT
-fcf-protection was added to the default CFLAGS in devtools 20211129, which is newer than the version zsnes 2.0.9-1 was compiled with. So 2.0.9-1 was also compiled without -fcf-protection, and there is no way this can be caused by these PKGBUILD lines. More likely caused by newer GCC / lto flags.
Comment by Allan McRae (Allan) - Saturday, 11 June 2022, 08:50 GMT
I'd bet this is a genuine buffer overflow, so is upstream issue. This is just being exposed due to newer gcc etc.
Comment by Alexander F. Rødseth (xyproto) - Saturday, 11 June 2022, 09:48 GMT
That makes sense. Thanks for the feedback. I'll close this issue and gather more information.
Comment by Alexander F. Rødseth (xyproto) - Sunday, 12 June 2022, 18:18 GMT
When building `zsnes` manually, Act Raiser 2 works fine, both with the release and the debug build.

With the `zsnes` package, just starting `zsnes` immediately gives:

*** buffer overflow detected ***: terminated
zsh: IOT instruction (core dumped) zsnes
Comment by Alexander F. Rødseth (xyproto) - Sunday, 12 June 2022, 20:47 GMT
Adding these two lines solved the issue:

export CFLAGS=${CFLAGS/-Wp,-D_FORTIFY_SOURCE=2/}
export CXXFLAGS=${CXXFLAGS/-Wp,-D_FORTIFY_SOURCE=2/}
Comment by Antonio Rojas (arojas) - Monday, 13 June 2022, 07:37 GMT
rpmfusion has some patches that look relevant:
https://github.com/rpmfusion/zsnes

can you test them?
Comment by Alexander F. Rødseth (xyproto) - Monday, 13 June 2022, 10:22 GMT
Thanks for the tip about the patches! Two of them made it possible to build with D_FORTIFY_SOURCE=2 again.

The `zsnes` repository now has a `2.0.10` tag with the patches applied, that works with D_FORTIFY_SOURCE=2 when testing locally here.
Comment by Alexander F. Rødseth (xyproto) - Monday, 13 June 2022, 11:53 GMT
It worked when I tested under Wayland, but now it does not work under X here. I will need to test/patch some more.
Comment by Alexander F. Rødseth (xyproto) - Sunday, 03 July 2022, 20:34 GMT
@arojas, my new key is not in archlinux-keyring yet.

Could you please package and push zsnes with these flags, just so that the package stops being broken?

export CFLAGS=${CFLAGS/-Wp,-D_FORTIFY_SOURCE=2/}
export CXXFLAGS=${CXXFLAGS/-Wp,-D_FORTIFY_SOURCE=2/}
Comment by Antonio Rojas (arojas) - Monday, 04 July 2022, 16:33 GMT
Done

Loading...