eden-miror/src/core/hle/service/psc
crueter c7b23f4a1a
[time] fix: guard timezone out buffer logging (#3668)
Original text, per the emailed patch:

---------------

Hello,

I am submitting a small fix to prevent an unintended abort when _GLIBCXX_ASSERTIONS is enabled, caused by out-of-bounds access in debug logging.
Background / Issue

In the server-side implementations of ITimeZoneService::ToPosixTime and ToPosixTimeWithMyRule, the SCOPE_EXIT debug logging previously accessed out_times[0] and out_times[1] unconditionally.

However, out_times is an IPC-provided output buffer (OutArray, which inherits from std::span). Its length depends on the caller-provided buffer capacity. During debugging, I encountered a case where out_times.size() == 1.

Under _GLIBCXX_ASSERTIONS, accessing out_times[1] triggers a std::span::operator[] assertion failure (std::__glibcxx_assert_fail) and aborts the process, causing the service thread to crash. This results in an unintended crash caused solely by debug logging.
Change Description

In the SCOPE_EXIT logging blocks of both ToPosixTime and ToPosixTimeWithMyRule, I added bounds checks before accessing out_times[0] and out_times[1]:

    Access out_times[0] only if out_times.size() > 0

    Access out_times[1] only if out_times.size() > 1

    Print 0 when the corresponding element is unavailable

This change only affects debug log output. It does not modify IPC semantics or the time conversion logic itself.
Reproduction Context (for reference)

I encountered this issue while running 13 Sentinels: Aegis Rim (title ID: 01008D7016438000). During the “Load Game” flow, ToPosixTimeWithMyRule is invoked with an out_times buffer of length 1, which previously led to the out-of-bounds access in the logging code.

Thank you for your time and review.

Best regards,
darkpaper

Environment: Arch Linux / KDE / X11

This email and the accompanying patch were prepared with assistance from
an LLM.

Authored-by: darkpaper <lirunzhou2021@gamil.com>
Signed-off-by: crueter <crueter@eden-emu.dev>

Co-authored-by: darkpaper <lirunzhou2021@gamil.com>
Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3668
2026-03-08 20:53:37 +01:00
..
ovln [hle,display,overlay,starter,hid] add overlay functions, starter applet (initially), HID handheld for system applets and fw21 stubs (#3080) 2025-11-27 19:46:41 +01:00
time [time] fix: guard timezone out buffer logging (#3668) 2026-03-08 20:53:37 +01:00
pm_control.cpp psc: move IPmControl, IPmModule, IPmService 2024-02-21 22:26:12 -05:00
pm_control.h psc: move IPmControl, IPmModule, IPmService 2024-02-21 22:26:12 -05:00
pm_module.cpp psc: move IPmControl, IPmModule, IPmService 2024-02-21 22:26:12 -05:00
pm_module.h psc: move IPmControl, IPmModule, IPmService 2024-02-21 22:26:12 -05:00
pm_service.cpp psc: rewrite IPmService 2024-02-21 22:26:32 -05:00
pm_service.h psc: rewrite IPmService 2024-02-21 22:26:32 -05:00
psc.cpp psc: stub overlay notification channel 2024-02-21 22:54:05 -05:00
psc.h psc: move IPmControl, IPmModule, IPmService 2024-02-21 22:26:12 -05:00