From 88e742927f886a7106f8bdd2c09ed4b7cc2cd083 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Mon, 3 Jun 2024 17:47:00 +0400 Subject: [PATCH] File descriptor fixes for XDPOpenWithDialog - Open it with O_CLOEXEC - Remove unneseccary std::array complication - Rely on Gio::UnixFDList to close it --- .../SourceFiles/platform/linux/file_utilities_linux.cpp | 7 +++---- Telegram/lib_base | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Telegram/SourceFiles/platform/linux/file_utilities_linux.cpp b/Telegram/SourceFiles/platform/linux/file_utilities_linux.cpp index d79e4778e..f314fb0af 100644 --- a/Telegram/SourceFiles/platform/linux/file_utilities_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/file_utilities_linux.cpp @@ -44,14 +44,12 @@ bool UnsafeShowOpenWith(const QString &filepath) { const auto fd = open( QFile::encodeName(filepath).constData(), - O_RDONLY); + O_RDONLY | O_CLOEXEC); if (fd == -1) { return false; } - const auto fdGuard = gsl::finally([&] { close(fd); }); - const auto handleToken = "tdesktop" + std::to_string(base::RandomValue()); @@ -73,6 +71,7 @@ bool UnsafeShowOpenWith(const QString &filepath) { nullptr)); if (!request) { + close(fd); return false; } @@ -107,7 +106,7 @@ bool UnsafeShowOpenWith(const QString &filepath) { GLib::Variant::new_variant( GLib::Variant::new_boolean(true))), }), - Gio::UnixFDList::new_from_array((std::array{ fd }).data(), 1), + Gio::UnixFDList::new_from_array(&fd, 1), nullptr); if (!result) { diff --git a/Telegram/lib_base b/Telegram/lib_base index e2c62ef0b..4d56f8b4b 160000 --- a/Telegram/lib_base +++ b/Telegram/lib_base @@ -1 +1 @@ -Subproject commit e2c62ef0b4581d84e4ff79623a7e5e9ed315bad7 +Subproject commit 4d56f8b4bba52b46844f46fafa5f9b6b2704429e