Skip to content

Commit

Permalink
Issue 333: fix handling of non-ASCII characters in file paths, bump 1…
Browse files Browse the repository at this point in the history
….18.1
  • Loading branch information
emcrisostomo committed Jan 18, 2025
1 parent 2cd9417 commit 9316445
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 25 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2014-2024 Enrico M. Crisostomo
# Copyright (c) 2014-2025 Enrico M. Crisostomo
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
Expand All @@ -14,7 +14,7 @@
# this program. If not, see <http://www.gnu.org/licenses/>.
#
cmake_minimum_required(VERSION 3.14)
project(fswatch VERSION 1.18.0 LANGUAGES C CXX)
project(fswatch VERSION 1.18.1 LANGUAGES C CXX)

#@formatter:off
set(PACKAGE "${PROJECT_NAME}")
Expand Down
5 changes: 5 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
NEWS
****

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
Expand Down
15 changes: 14 additions & 1 deletion libfswatch/src/libfswatch/c++/fsevents_monitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,22 @@ namespace fsw
kFSEventStreamEventExtendedDataPathKey));
auto cf_inode = static_cast<CFNumberRef>(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<char> 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);
Expand Down
4 changes: 2 additions & 2 deletions m4/fswatch_version.m4
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2014-2024 Enrico M. Crisostomo
# Copyright (c) 2014-2025 Enrico M. Crisostomo
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
Expand All @@ -13,5 +13,5 @@
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
#
m4_define([FSWATCH_VERSION], [1.18.0])
m4_define([FSWATCH_VERSION], [1.18.1])
m4_define([FSWATCH_REVISION], [1])
6 changes: 3 additions & 3 deletions m4/libfswatch_version.m4
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2014-2024 Enrico M. Crisostomo
# Copyright (c) 2014-2025 Enrico M. Crisostomo
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
Expand Down Expand Up @@ -37,6 +37,6 @@
#
# Libtool documentation, 7.3 Updating library version information
#
m4_define([LIBFSWATCH_VERSION], [1.18.0])
m4_define([LIBFSWATCH_API_VERSION], [13:1:0])
m4_define([LIBFSWATCH_VERSION], [1.18.1])
m4_define([LIBFSWATCH_API_VERSION], [13:2:0])
m4_define([LIBFSWATCH_REVISION], [1])
4 changes: 2 additions & 2 deletions po/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: fswatch 1.11.3\n"
"Report-Msgid-Bugs-To: [email protected]\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 <[email protected]>\n"
"Language-Team: English\n"
Expand Down Expand Up @@ -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 ""

Expand Down
8 changes: 4 additions & 4 deletions po/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -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: [email protected]\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"
Expand Down Expand Up @@ -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"

Expand Down
8 changes: 4 additions & 4 deletions po/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -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: [email protected]\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"
Expand Down Expand Up @@ -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"

Expand Down
4 changes: 2 additions & 2 deletions po/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: fswatch 1.11.3\n"
"Report-Msgid-Bugs-To: [email protected]\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 <[email protected]>\n"
"Language-Team: Spanish <[email protected]>\n"
Expand Down Expand Up @@ -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"

Expand Down
6 changes: 3 additions & 3 deletions po/fswatch.pot
Original file line number Diff line number Diff line change
Expand Up @@ -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: [email protected]\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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -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 ""

Expand Down
4 changes: 2 additions & 2 deletions po/it.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: fswatch 1.11.3\n"
"Report-Msgid-Bugs-To: [email protected]\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 <[email protected]>\n"
"Language-Team: Italian <[email protected]>\n"
Expand Down Expand Up @@ -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"

Expand Down

0 comments on commit 9316445

Please sign in to comment.