fix(libSceLibreSsl): honor CONF_MFLAGS_IGNORE_RETURN_CODES in CONF_modules_load_file #25189

Merged
gurtgg merged 1 commit from upstream-pr/25189 into main 2026-11-21 20:39:55 +00:00
gurtgg commented 2026-11-21 19:23:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by gurtgg on 2026-11-21T19:23:49Z.


What

  • Update CONF_modules_load_file_nid_postfix (core/libs/prx/libSceLibreSsl/src/Conf.cpp) to honor CONF_MFLAGS_IGNORE_RETURN_CODES (0x2): return 1 instead of 0 on CONF allocation failure, default-path asprintf failure, and missing/unopenable configuration files when IgnoreReturnCodes is set, while preserving queued errors unless CONF_MFLAGS_IGNORE_MISSING_FILE (0x10) matched CONF_R_NO_SUCH_FILE (matching LibreSSL 2.5.4 conf_mod.c v1.27).
  • Map both guest ENOENT (2) and ENXIO (6) to BIO_R_NO_SUCH_FILE (128) in Opens() (matching LibreSSL 2.5.4 bss_file.c v1.32).

Tested

  • Added ConfLoadFileIgnoreReturnCodes and ConfLoadFileIgnoreReturnCodesAllocator in core/libs/prx/libSceLibreSsl/tests/X509VerifyParam.cpp exercising CONF_modules_load_file_nid_postfix on a missing file with flags=0 (returns 0 with SYS/BIO/CONF errors queued), flags=0x2 (negative control: returns 0 before fix, 1 after fix with the 3 queued errors preserved), flags=0x10 (returns 1 and clears the error queue), and under failNext=true with flags=0x2 (returns 1 with CONF_R_MALLOC_FAILURE queued).

Checklist

  • tools/check_conventions.py passes (UTF-8 no-BOM LF, zero disallowed comments, Conventional Commits)
  • Negative-control regression test fails against unmodified main and passes after fix
  • AI-assisted: yes
  • Depends on: none
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5431568080 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/25189). Originally posted by [gurtgg](https://github.com/gurtgg) on 2026-11-21T19:23:49Z. --- ### What - Update `CONF_modules_load_file_nid_postfix` (`core/libs/prx/libSceLibreSsl/src/Conf.cpp`) to honor `CONF_MFLAGS_IGNORE_RETURN_CODES` (`0x2`): return `1` instead of `0` on `CONF` allocation failure, default-path `asprintf` failure, and missing/unopenable configuration files when `IgnoreReturnCodes` is set, while preserving queued errors unless `CONF_MFLAGS_IGNORE_MISSING_FILE` (`0x10`) matched `CONF_R_NO_SUCH_FILE` (matching LibreSSL 2.5.4 `conf_mod.c` v1.27). - Map both guest `ENOENT` (`2`) and `ENXIO` (`6`) to `BIO_R_NO_SUCH_FILE` (`128`) in `Opens()` (matching LibreSSL 2.5.4 `bss_file.c` v1.32). ### Tested - Added `ConfLoadFileIgnoreReturnCodes` and `ConfLoadFileIgnoreReturnCodesAllocator` in `core/libs/prx/libSceLibreSsl/tests/X509VerifyParam.cpp` exercising `CONF_modules_load_file_nid_postfix` on a missing file with `flags=0` (returns `0` with SYS/BIO/CONF errors queued), `flags=0x2` (negative control: returns `0` before fix, `1` after fix with the 3 queued errors preserved), `flags=0x10` (returns `1` and clears the error queue), and under `failNext=true` with `flags=0x2` (returns `1` with `CONF_R_MALLOC_FAILURE` queued). ### Checklist - [x] `tools/check_conventions.py` passes (UTF-8 no-BOM LF, zero disallowed comments, Conventional Commits) - [x] Negative-control regression test fails against unmodified `main` and passes after fix - AI-assisted: yes - Depends on: none
PrivacyOnion commented 2026-11-21 19:36:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-21T19:36:35Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against d61020bbd9:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_libressl_x509_verify_param_tests built cleanly.
  • CTest (guest_libressl_x509_verify_param, guest_libressl_x509_verify_param_allocator):
    1/2 Test #4635: guest_libressl_x509_verify_param .............   Passed    0.03 sec
    2/2 Test #4636: guest_libressl_x509_verify_param_allocator ...   Passed    0.02 sec
    100% tests passed, 0 tests failed out of 2
    
  • Negative control: with core/libs/prx/libSceLibreSsl/src/Conf.cpp reverted to main and the new tests kept, the suite fails:
    1/2 Test #4636: guest_libressl_x509_verify_param_allocator ...Subprocess aborted***Exception:   0.51 sec
    2/2 Test #4635: guest_libressl_x509_verify_param .............Subprocess aborted***Exception:   0.58 sec
    0% tests passed, 2 tests failed out of 2
    
    Restoring the change makes it pass again.
  • Code reading:
    • Verified that CONF_modules_load_file_nid_postfix correctly returns 1 instead of 0 when flags has CONF_MFLAGS_IGNORE_RETURN_CODES (0x2) set, both on early malloc failure and on missing/unopened configuration file in core/libs/prx/libSceLibreSsl/src/Conf.cpp.
    • Verified that error queue preservation adheres to LibreSSL upstream behavior: CONF_MFLAGS_IGNORE_RETURN_CODES leaves queued errors intact, whereas CONF_MFLAGS_IGNORE_MISSING_FILE (0x10) clears them via ERR_clear_error_nid_postfix().
    • Verified the addition of GuestNoSuchDeviceOrAddress (ENXIO=6) alongside GuestNoSuchFile (ENOENT=2) mapping to BioNoSuchFile in Opens() matches LibreSSL 2.5.4 bss_file.c behavior.
    • Audited pointer handling and lifetime in cleanup lambda: free_nid_postfix safely handles null pointers via std::exchange, avoiding double free or leak.
    • Verified AGENTS.md rules compliance: zero forbidden comments, no stubs returning fake success for existing files (NotImplemented_nid_no_patch is called if file exists), and no extra untracked files.
    • Verified test coverage in core/libs/prx/libSceLibreSsl/tests/X509VerifyParam.cpp cleanly tests missing file without flags, with 0x2, with 0x10, and allocation failure with 0x2 without leaking temporary directories.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6007710007 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/25189#pullrequestreview-6007710007). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-21T19:36:35Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `d61020bbd9`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_libressl_x509_verify_param_tests` built cleanly. - **CTest** (`guest_libressl_x509_verify_param`, `guest_libressl_x509_verify_param_allocator`): ``` 1/2 Test #4635: guest_libressl_x509_verify_param ............. Passed 0.03 sec 2/2 Test #4636: guest_libressl_x509_verify_param_allocator ... Passed 0.02 sec 100% tests passed, 0 tests failed out of 2 ``` - **Negative control**: with `core/libs/prx/libSceLibreSsl/src/Conf.cpp` reverted to `main` and the new tests kept, the suite fails: ``` 1/2 Test #4636: guest_libressl_x509_verify_param_allocator ...Subprocess aborted***Exception: 0.51 sec 2/2 Test #4635: guest_libressl_x509_verify_param .............Subprocess aborted***Exception: 0.58 sec 0% tests passed, 2 tests failed out of 2 ``` Restoring the change makes it pass again. - **Code reading**: - Verified that CONF_modules_load_file_nid_postfix correctly returns 1 instead of 0 when flags has CONF_MFLAGS_IGNORE_RETURN_CODES (0x2) set, both on early malloc failure and on missing/unopened configuration file in core/libs/prx/libSceLibreSsl/src/Conf.cpp. - Verified that error queue preservation adheres to LibreSSL upstream behavior: CONF_MFLAGS_IGNORE_RETURN_CODES leaves queued errors intact, whereas CONF_MFLAGS_IGNORE_MISSING_FILE (0x10) clears them via ERR_clear_error_nid_postfix(). - Verified the addition of GuestNoSuchDeviceOrAddress (ENXIO=6) alongside GuestNoSuchFile (ENOENT=2) mapping to BioNoSuchFile in Opens() matches LibreSSL 2.5.4 bss_file.c behavior. - Audited pointer handling and lifetime in cleanup lambda: free_nid_postfix safely handles null pointers via std::exchange, avoiding double free or leak. - Verified AGENTS.md rules compliance: zero forbidden comments, no stubs returning fake success for existing files (NotImplemented_nid_no_patch is called if file exists), and no extra untracked files. - Verified test coverage in core/libs/prx/libSceLibreSsl/tests/X509VerifyParam.cpp cleanly tests missing file without flags, with 0x2, with 0x10, and allocation failure with 0x2 without leaking temporary directories. Looks Good To Me
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!25189
No description provided.