Skip to content

Commit 089401c

Browse files
committed
fix: refuse to open overly long URLs
ShellExecute on Wine can crash if you feed it a too long URL and some browsers have been documented to have a fairly low max limit of 2083 characters. This rejects URLs that are longer than 2048 characters.
1 parent a1cd16c commit 089401c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

engine/system/win/sys_main.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,11 @@ void sys_main_c::SpawnProcess(const char* cmdName, const char* argList)
412412
void PlatformOpenURL(const char* url)
413413
{
414414
#ifdef _WIN32
415-
ShellExecuteA(NULL, "open", url, NULL, NULL, SW_SHOWDEFAULT);
415+
// There is a surprisingly low limit for the maximum URL length that ShellExecute and browsers can open.
416+
// A common lower limit is 2083, so we'll refuse to open URLs smaller than this.
417+
// Wine crashes violently if this is violated, 2k should be a safe enough limit while still allowing rather long links.
418+
if (strlen(url) < 2048)
419+
ShellExecuteA(NULL, "open", url, NULL, NULL, SW_SHOWDEFAULT);
416420
#else
417421
#warning LV: URL opening not implemented on this OS.
418422
// TODO(LV): Implement URL opening for other OSes.

0 commit comments

Comments
 (0)