fix: correct sscanf %x signedness and avoid a substr copy #15

Merged
obelisk-complex merged 1 commit from upstream-pr/15 into main 2026-09-27 08:30:51 +00:00
obelisk-complex commented 2026-09-26 20:13:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by obelisk-complex on 2026-09-26T20:13:31Z.


libSceSysmodule/Export.cpp parsed /proc/self/maps device major/minor numbers into signed int with a %x format, which is undefined behaviour per the C standard even though it happened to work on this target; switched to unsigned int to match the format specifier.

NidPatcherUtils.hpp's StripNidPostfix built a truncated copy with substr(0, n) where the prefix is already the string itself; resize(n) does the same truncation without the extra allocation and copy.

Changes

  • core/libs/prx/libSceSysmodule/Export.cpp: devMajor/devMinor now unsigned int.
  • core/libs/nid/include/nid/NidPatcherUtils.hpp: two substr(0, n) calls replaced with resize(n).

Testing (Linux, GCC)

  • Full build succeeds.
  • ctest: 23/30, the same 7 pre-existing failures as on main, unaffected by this change.

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4649403466 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15). Originally posted by [obelisk-complex](https://github.com/obelisk-complex) on 2026-09-26T20:13:31Z. --- `libSceSysmodule/Export.cpp` parsed `/proc/self/maps` device major/minor numbers into `signed int` with a `%x` format, which is undefined behaviour per the C standard even though it happened to work on this target; switched to `unsigned int` to match the format specifier. `NidPatcherUtils.hpp`'s `StripNidPostfix` built a truncated copy with `substr(0, n)` where the prefix is already the string itself; `resize(n)` does the same truncation without the extra allocation and copy. Changes - `core/libs/prx/libSceSysmodule/Export.cpp`: `devMajor`/`devMinor` now `unsigned int`. - `core/libs/nid/include/nid/NidPatcherUtils.hpp`: two `substr(0, n)` calls replaced with `resize(n)`. Testing (Linux, GCC) - Full build succeeds. - `ctest`: 23/30, the same 7 pre-existing failures as on `main`, unaffected by this change. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!15
No description provided.