1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-01-30 10:52:00 +00:00

fix: potential NSString leak in tr_strv_convert_utf8()

This commit is contained in:
Cœur 2023-04-12 06:36:22 +08:00 committed by GitHub
parent c76cb4db51
commit 91717fe91d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 62 additions and 44 deletions

View file

@ -3717,7 +3717,6 @@
buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "c++17";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_OBJC_ARC = NO;
HEADER_SEARCH_PATHS = (
"$(inherited)",
"third-party/dht",
@ -3961,7 +3960,6 @@
buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "c++17";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_OBJC_ARC = NO;
HEADER_SEARCH_PATHS = (
"$(inherited)",
"third-party/dht",
@ -4277,7 +4275,6 @@
buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "c++17";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_OBJC_ARC = NO;
HEADER_SEARCH_PATHS = (
"$(inherited)",
"third-party/dht",

View file

@ -10,6 +10,10 @@ endif()
check_symbol_exists(SO_REUSEPORT "sys/types.h;sys/socket.h" HAVE_SO_REUSEPORT)
add_compile_options(
# equivalent of XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC YES for this directory
$<$<AND:$<BOOL:${APPLE}>,$<COMPILE_LANGUAGE:C,CXX>>:-fobjc-arc>)
add_library(${TR_NAME} STATIC)
target_sources(${TR_NAME}

View file

@ -15,8 +15,12 @@
std::string tr_strv_convert_utf8(std::string_view sv)
{
// local pool for non-app tools like transmission-daemon, transmission-remote, transmission-create, ...
@autoreleasepool
{
// UTF-8 encoding
char const* validUTF8 = [[NSString alloc] initWithBytes:std::data(sv) length:std::size(sv) encoding:NSUTF8StringEncoding].UTF8String;
char const* validUTF8 = [[NSString alloc] initWithBytes:std::data(sv) length:std::size(sv) encoding:NSUTF8StringEncoding]
.UTF8String;
if (validUTF8)
{
return std::string(validUTF8);
@ -46,4 +50,5 @@ std::string tr_strv_convert_utf8(std::string_view sv)
// invalid encoding
return tr_strv_replace_invalid(sv);
}
}

View file

@ -1,20 +1,32 @@
# minimum macOS target support
if(CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS MACOS_SUPPORT_MINIMUM)
message(FATAL_ERROR "Targeting macOS versions before ${MACOS_SUPPORT_MINIMUM} is not supported for the macOS project, please adjust CMAKE_OSX_DEPLOYMENT_TARGET (${CMAKE_OSX_DEPLOYMENT_TARGET})")
endif()
find_program(ACTOOL_EXECUTABLE actool REQUIRED)
find_program(CODESIGN_EXECUTABLE codesign REQUIRED)
set(MAC_BUNDLE_NAME Transmission)
add_compile_options(
-fcxx-modules
-fmodules
-fobjc-arc
# #warnings are good practice in development
"-Wno-#warnings"
# GNU extensions are good practice in Objective-C
-Wno-gnu)
$<$<COMPILE_LANGUAGE:C,CXX>:-fmodules>
$<$<COMPILE_LANGUAGE:C,CXX>:-fcxx-modules>
find_program(ACTOOL_EXECUTABLE actool REQUIRED)
find_program(CODESIGN_EXECUTABLE codesign REQUIRED)
# equivalent of XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC YES for this directory
$<$<COMPILE_LANGUAGE:C,CXX>:-fobjc-arc>
# equivalent of XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_WEAK YES for this directory
$<$<COMPILE_LANGUAGE:C,CXX>:-fobjc-weak>
# GNU extensions are good practice in Objective-C
$<$<COMPILE_LANGUAGE:C,CXX>:-Wno-gnu>
# Our #warnings are good practice in IDE development, not in command-line compilation
$<$<AND:$<NOT:$<BOOL:${XCODE}>>,$<COMPILE_LANGUAGE:C,CXX>>:-Wno-\#warnings>)
add_link_options(
# equivalent of XCODE_ATTRIBUTE_DEAD_CODE_STRIPPING YES for this directory
$<$<LINK_LANGUAGE:C,CXX>:-dead_strip>)
add_subdirectory(QuickLookPlugin)
add_subdirectory(VDKQueue)
@ -411,10 +423,10 @@ endif()
set_target_properties(
${TR_NAME}-mac
PROPERTIES
OUTPUT_NAME ${MAC_BUNDLE_NAME}
INSTALL_RPATH "@executable_path;@executable_path/../Frameworks"
MACOSX_BUNDLE_GUI_IDENTIFIER "org.m0k.transmission"
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist.in
INSTALL_RPATH "@executable_path;@executable_path/../Frameworks")
OUTPUT_NAME ${MAC_BUNDLE_NAME})
install(
TARGETS ${TR_NAME}-mac

View file

@ -1,3 +1,5 @@
set(MAC_QL_BUNDLE_NAME QuickLookPlugin)
add_library(${TR_NAME}-mac-ql MODULE)
target_sources(${TR_NAME}-mac-ql
@ -61,17 +63,15 @@ target_sources(${TR_NAME}-mac-ql
PRIVATE
${RESOURCES})
set(MAC_QL_BUNDLE_NAME QuickLookPlugin)
set_target_properties(
${TR_NAME}-mac-ql
PROPERTIES
OUTPUT_NAME ${MAC_QL_BUNDLE_NAME}
MACOSX_BUNDLE ON
BUNDLE ON
BUNDLE_EXTENSION qlgenerator
INSTALL_RPATH "@loader_path/../../../../../MacOS;@loader_path/../../../../../Frameworks"
MACOSX_BUNDLE ON
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/Info.plist.in"
INSTALL_RPATH "@loader_path/../../../../../MacOS;@loader_path/../../../../../Frameworks")
OUTPUT_NAME ${MAC_QL_BUNDLE_NAME})
target_include_directories(${TR_NAME}-mac-ql
PRIVATE