Lib.Ssl2: Stub data for sceSslGetCaCerts (#4127)

* Test

* More robust logic for storing and freeing dummy data

Anything heap allocated is invalidated when the function returns. Use malloc to allocate the string instead, and make sure to free those allocations in sceSslFreeCaCerts.
This commit is contained in:
Stephen Miller 2026-03-14 10:12:26 -05:00 committed by GitHub
parent f336096b12
commit 844cfe5185
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -114,7 +114,13 @@ int PS4_SYSV_ABI sceSslFreeCaCerts(s32 ssl_ctx_id, OrbisSslCaCerts* certs) {
if (certs == nullptr) {
return ORBIS_SSL_ERROR_INVALID_ARGUMENT;
}
delete (certs->certs);
if (certs->certs != nullptr) {
for (s32 data = 0; data < certs->num; data++) {
free(certs->certs[data].ptr);
}
delete (certs->certs);
}
// delete (certs->pool);
return ORBIS_OK;
}
@ -139,7 +145,12 @@ int PS4_SYSV_ABI sceSslGetCaCerts(s32 ssl_ctx_id, OrbisSslCaCerts* certs) {
if (certs == nullptr) {
return ORBIS_SSL_ERROR_INVALID_ARGUMENT;
}
certs->certs = new OrbisSslData{nullptr, 0};
// Allocate a buffer to store dummy data in.
const char* dummy_data = "dummy";
u64 dummy_length = strlen(dummy_data) + 1;
char* data = static_cast<char*>(malloc(dummy_length));
strncpy(data, dummy_data, dummy_length);
certs->certs = new OrbisSslData{data, dummy_length};
certs->num = 1;
certs->pool = nullptr;
return ORBIS_OK;