firefox/D210158.1715685536.diff

55 lines
1.8 KiB
Diff
Raw Normal View History

2024-05-14 09:29:26 +00:00
diff -up firefox-126.0/widget/gtk/DBusService.cpp.D210158.1715685536 firefox-126.0/widget/gtk/DBusService.cpp
--- firefox-126.0/widget/gtk/DBusService.cpp.D210158.1715685536 2024-05-14 11:19:02.098199593 +0200
+++ firefox-126.0/widget/gtk/DBusService.cpp 2024-05-14 11:24:44.236939835 +0200
@@ -85,38 +85,24 @@ static const char* kIntrospectTemplate =
bool DBusService::LaunchApp(const char* aCommand, const char** aURIList,
int aURIListLen) {
- // Allocate space for all uris, executable name, command if supplied and
- // null terminator
- int paramsNum = aURIListLen + 2;
+ nsAutoCString param(mAppFile);
if (aCommand) {
- paramsNum++;
- }
-
- char** argv = (char**)moz_xmalloc(sizeof(char*) * paramsNum);
- int argc = 0;
- argv[argc++] = strdup(mAppFile);
- if (aCommand) {
- argv[argc++] = strdup(aCommand);
+ param.Append(" ");
+ param.Append(aCommand);
}
for (int i = 0; aURIList && i < aURIListLen; i++) {
- argv[argc++] = strdup(aURIList[i]);
- }
- argv[argc++] = nullptr;
-
- nsAutoCString exePath;
- nsCOMPtr<nsIFile> lf;
- bool ret = false;
- if (NS_SUCCEEDED(XRE_GetBinaryPath(getter_AddRefs(lf)))) {
- if (NS_SUCCEEDED(lf->GetNativePath(exePath))) {
- ret = (PR_CreateProcessDetached(exePath.get(), argv, nullptr, nullptr) !=
- PR_FAILURE);
- }
+ param.Append(" ");
2024-05-14 09:29:26 +00:00
+ GUniquePtr<char> escUri(g_shell_quote(aURIList[i]));
+ param.Append(escUri.get());
}
- for (int i = 0; i < argc; i++) {
- free(argv[i]);
+ char* argv[] = {strdup("/bin/sh"), strdup("-c"), strdup(param.get()),
+ nullptr};
+ int ret =
+ PR_CreateProcessDetached("/bin/sh", argv, nullptr, nullptr) != PR_FAILURE;
+ for (auto str : argv) {
+ free(str);
}
- free(argv);
return ret;
}