diff --git a/NEWS b/NEWS index 7f277ad7..5376190a 100644 --- a/NEWS +++ b/NEWS @@ -11,6 +11,11 @@ New in current-develop: * inotify_monitor: added support for CloseWrite, adding support for events of type IN_CLOSE_WRITE. +New in 1.18.1: + + * Issue 333: Fix: Handle non-ASCII characters in file paths to prevent + segmentation faults in FSEvents callback. + New in 1.18.0: * The C++17 standard has been adopted: code has been rewritten and simplified diff --git a/libfswatch/src/libfswatch/c++/fsevents_monitor.cpp b/libfswatch/src/libfswatch/c++/fsevents_monitor.cpp index 24573c43..ebded1e5 100644 --- a/libfswatch/src/libfswatch/c++/fsevents_monitor.cpp +++ b/libfswatch/src/libfswatch/c++/fsevents_monitor.cpp @@ -197,9 +197,22 @@ namespace fsw kFSEventStreamEventExtendedDataPathKey)); auto cf_inode = static_cast(CFDictionaryGetValue(path_info_dict, kFSEventStreamEventExtendedFileIDKey)); + + // Get the length of the UTF8-encoded CFString in bytes + CFIndex length = CFStringGetLength(path); + CFIndex max_path_size = CFStringGetMaximumSizeForEncoding(length, kCFStringEncodingUTF8) + 1; + + // Allocate a buffer dynamically + std::vector path_buffer(max_path_size); + if (!CFStringGetCString(path, path_buffer.data(), max_path_size, kCFStringEncodingUTF8)) + { + std::cerr << "Warning: Failed to convert CFStringRef to C string." << std::endl; + continue; + } + unsigned long inode; CFNumberGetValue(cf_inode, kCFNumberLongType, &inode); - events.emplace_back(std::string(CFStringGetCStringPtr(path, kCFStringEncodingUTF8)), + events.emplace_back(std::string(path_buffer.data()), curr_time, decode_flags(eventFlags[i]), inode); diff --git a/po/en.po b/po/en.po index a7a0323b..d9f3f3ac 100644 --- a/po/en.po +++ b/po/en.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: fswatch 1.11.3\n" "Report-Msgid-Bugs-To: enrico.m.crisostomo@gmail.com\n" -"POT-Creation-Date: 2025-01-03 13:06+0100\n" +"POT-Creation-Date: 2025-01-18 01:36+0100\n" "PO-Revision-Date: 2017-10-29 14:04+0100\n" "Last-Translator: Enrico Maria Crisostomo \n" "Language-Team: English\n" @@ -380,7 +380,7 @@ msgstr "" msgid "The callback info cannot be cast to fsevents_monitor." msgstr "" -#: libfswatch/src/libfswatch/c++/fsevents_monitor.cpp:246 +#: libfswatch/src/libfswatch/c++/fsevents_monitor.cpp:259 msgid "Creating FSEvent stream...\n" msgstr "" diff --git a/po/en@boldquot.po b/po/en@boldquot.po index f7fd16b1..604f5fa7 100644 --- a/po/en@boldquot.po +++ b/po/en@boldquot.po @@ -30,10 +30,10 @@ # msgid "" msgstr "" -"Project-Id-Version: fswatch 1.18.0\n" +"Project-Id-Version: fswatch 1.18.1\n" "Report-Msgid-Bugs-To: enrico.m.crisostomo@gmail.com\n" -"POT-Creation-Date: 2025-01-03 13:06+0100\n" -"PO-Revision-Date: 2025-01-03 13:06+0100\n" +"POT-Creation-Date: 2025-01-18 01:36+0100\n" +"PO-Revision-Date: 2025-01-18 01:36+0100\n" "Last-Translator: Automatically generated\n" "Language-Team: none\n" "Language: en@boldquot\n" @@ -413,7 +413,7 @@ msgstr "Releasing event stream...\n" msgid "The callback info cannot be cast to fsevents_monitor." msgstr "The callback info cannot be cast to fsevents_monitor." -#: libfswatch/src/libfswatch/c++/fsevents_monitor.cpp:246 +#: libfswatch/src/libfswatch/c++/fsevents_monitor.cpp:259 msgid "Creating FSEvent stream...\n" msgstr "Creating FSEvent stream...\n" diff --git a/po/en@quot.po b/po/en@quot.po index 874a9c8e..497432dc 100644 --- a/po/en@quot.po +++ b/po/en@quot.po @@ -27,10 +27,10 @@ # msgid "" msgstr "" -"Project-Id-Version: fswatch 1.18.0\n" +"Project-Id-Version: fswatch 1.18.1\n" "Report-Msgid-Bugs-To: enrico.m.crisostomo@gmail.com\n" -"POT-Creation-Date: 2025-01-03 13:06+0100\n" -"PO-Revision-Date: 2025-01-03 13:06+0100\n" +"POT-Creation-Date: 2025-01-18 01:36+0100\n" +"PO-Revision-Date: 2025-01-18 01:36+0100\n" "Last-Translator: Automatically generated\n" "Language-Team: none\n" "Language: en@quot\n" @@ -410,7 +410,7 @@ msgstr "Releasing event stream...\n" msgid "The callback info cannot be cast to fsevents_monitor." msgstr "The callback info cannot be cast to fsevents_monitor." -#: libfswatch/src/libfswatch/c++/fsevents_monitor.cpp:246 +#: libfswatch/src/libfswatch/c++/fsevents_monitor.cpp:259 msgid "Creating FSEvent stream...\n" msgstr "Creating FSEvent stream...\n" diff --git a/po/es.po b/po/es.po index 68ea912a..75bebf35 100644 --- a/po/es.po +++ b/po/es.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: fswatch 1.11.3\n" "Report-Msgid-Bugs-To: enrico.m.crisostomo@gmail.com\n" -"POT-Creation-Date: 2025-01-03 13:06+0100\n" +"POT-Creation-Date: 2025-01-18 01:36+0100\n" "PO-Revision-Date: 2017-10-29 14:04+0100\n" "Last-Translator: Enrico Maria Crisostomo \n" "Language-Team: Spanish \n" @@ -391,7 +391,7 @@ msgstr "Liberando el flujo de eventos...\n" msgid "The callback info cannot be cast to fsevents_monitor." msgstr "El context de callback no puede convertirse a fsevents_monitor." -#: libfswatch/src/libfswatch/c++/fsevents_monitor.cpp:246 +#: libfswatch/src/libfswatch/c++/fsevents_monitor.cpp:259 msgid "Creating FSEvent stream...\n" msgstr "Creando el flujo FSEvent...\n" diff --git a/po/fswatch.pot b/po/fswatch.pot index 6c7665c6..27cab1cf 100644 --- a/po/fswatch.pot +++ b/po/fswatch.pot @@ -6,9 +6,9 @@ #, fuzzy msgid "" msgstr "" -"Project-Id-Version: fswatch 1.18.0\n" +"Project-Id-Version: fswatch 1.18.1\n" "Report-Msgid-Bugs-To: enrico.m.crisostomo@gmail.com\n" -"POT-Creation-Date: 2025-01-03 13:06+0100\n" +"POT-Creation-Date: 2025-01-18 01:36+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -380,7 +380,7 @@ msgstr "" msgid "The callback info cannot be cast to fsevents_monitor." msgstr "" -#: libfswatch/src/libfswatch/c++/fsevents_monitor.cpp:246 +#: libfswatch/src/libfswatch/c++/fsevents_monitor.cpp:259 msgid "Creating FSEvent stream...\n" msgstr "" diff --git a/po/it.po b/po/it.po index 34979c94..abce2fe1 100644 --- a/po/it.po +++ b/po/it.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: fswatch 1.11.3\n" "Report-Msgid-Bugs-To: enrico.m.crisostomo@gmail.com\n" -"POT-Creation-Date: 2025-01-03 13:06+0100\n" +"POT-Creation-Date: 2025-01-18 01:36+0100\n" "PO-Revision-Date: 2018-05-02 17:29+0200\n" "Last-Translator: Enrico Maria Crisostomo \n" "Language-Team: Italian \n" @@ -391,7 +391,7 @@ msgstr "Liberando il flusso di eventi...\n" msgid "The callback info cannot be cast to fsevents_monitor." msgstr "Il contesto del callback non può essere convertita a fsevents_monitor." -#: libfswatch/src/libfswatch/c++/fsevents_monitor.cpp:246 +#: libfswatch/src/libfswatch/c++/fsevents_monitor.cpp:259 msgid "Creating FSEvent stream...\n" msgstr "Creando il flusso FSEvent...\n"