net: accept a NULL user agent in sceHttpCreateTemplate (Cyberpunk 2077)

This commit is contained in:
nmzik
2026-10-23 07:42:28 +02:00
parent f9e14084d6
commit 87e815b250
2 changed files with 14 additions and 1 deletions
+1 -1
View File
@@ -466,7 +466,7 @@ Network::Id Network::HttpCreateTemplate(Id http_ctx_id, const char* user_agent,
HttpTemplate tn {};
tn.used = true;
tn.http_ver = http_ver;
tn.user_agent = std::string(user_agent);
tn.user_agent = user_agent != nullptr ? user_agent : "";
tn.is_auto_proxy_conf = is_auto_proxy_conf;
tn.http_ctx_id = http_ctx_id.GetId();
tn.nonblock = false;
+13
View File
@@ -1,4 +1,5 @@
#include "common/abi.h"
#include "libs/network.h"
#include "loader/symbolDatabase.h"
#include <array>
@@ -162,6 +163,17 @@ void TestBuildHonoursOption(HttpUriParse parse, HttpUriBuild build) {
CHECK(BuildWith(build, element, 0) == url);
}
// Cyberpunk 2077 (PPSA03974) creates a template with a NULL user agent.
void TestTemplateWithoutUserAgent() {
using namespace Libs::Network;
Initialize();
const int pool = Net::NetPoolCreate("http", 0x10000, 0);
const int ssl = Ssl::SslInit(0x10000);
const int http = Http::HttpInit(pool, ssl, 0x10000);
CHECK(Http::HttpCreateTemplate(http, nullptr, 2, 1) > 0);
Shutdown();
}
} // namespace
int main() {
@@ -176,5 +188,6 @@ int main() {
TestAbsentQuery(parse);
TestEmptyUri(parse);
TestPresentQuery(parse);
TestTemplateWithoutUserAgent();
return failures == 0 ? 0 : 1;
}