From 1b341850e02031a10cb066ff42d7b606ffa500f2 Mon Sep 17 00:00:00 2001 From: Willi Mann Date: Thu, 3 Dec 2020 09:37:26 +0100 Subject: [PATCH 1/4] prevent using watches after delete The first thing UserTable::OnEvent does is to Dispose(). This deletes all watches making all pointers to watches invalid. But the original watch is needed to exand the $@ path. This gets the string out of the watch before it is deleted by Dispose() and the pointer becomes invalid. --- usertable.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/usertable.cpp b/usertable.cpp index 11fd04b..0f9e8e3 100644 --- a/usertable.cpp +++ b/usertable.cpp @@ -370,6 +370,7 @@ void UserTable::OnEvent(InotifyEvent& rEvt) { InotifyWatch* pW = rEvt.GetWatch(); IncronTabEntry* pE = FindEntry(pW); + std::string pWPath = pW->GetPath(); // no entry found - this shouldn't occur if (pE == NULL) @@ -422,7 +423,7 @@ void UserTable::OnEvent(InotifyEvent& rEvt) else { cmd.append(cs.substr(oldpos, pos-oldpos)); if (cs[px] == '@') { // base path - cmd.append(IncronTabEntry::GetSafePath(pW->GetPath())); + cmd.append(IncronTabEntry::GetSafePath(pWPath)); oldpos = pos + 2; } else if (cs[px] == '#') { // file name From a2c7e3be063ad05fe911290f163bd306fdc17736 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Schplurtz=20le=20D=C3=A9boulonn=C3=A9?= Date: Thu, 3 Dec 2020 09:55:35 +0100 Subject: [PATCH 2/4] call GetSafePath only if needed also stick to apparent naming convention. --- usertable.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usertable.cpp b/usertable.cpp index 0f9e8e3..f4710b6 100644 --- a/usertable.cpp +++ b/usertable.cpp @@ -370,7 +370,6 @@ void UserTable::OnEvent(InotifyEvent& rEvt) { InotifyWatch* pW = rEvt.GetWatch(); IncronTabEntry* pE = FindEntry(pW); - std::string pWPath = pW->GetPath(); // no entry found - this shouldn't occur if (pE == NULL) @@ -387,6 +386,7 @@ void UserTable::OnEvent(InotifyEvent& rEvt) syslog(LOG_INFO, "PATH (%s) FILE (%s) EVENT (%s)", pW->GetPath().c_str() , IncronTabEntry::GetSafePath(rEvt.GetName()).c_str() , events.c_str()); //#endif + std::string WPath = pW->GetPath(); // FIXME: Should Dispose() be moved after "$@" param is treated ? // add new watch for newly created subdirs if ( rEvt.IsType(IN_ISDIR) && (rEvt.IsType(IN_CREATE) || rEvt.IsType(IN_MOVED_TO)) ) { @@ -423,7 +423,7 @@ void UserTable::OnEvent(InotifyEvent& rEvt) else { cmd.append(cs.substr(oldpos, pos-oldpos)); if (cs[px] == '@') { // base path - cmd.append(IncronTabEntry::GetSafePath(pWPath)); + cmd.append(IncronTabEntry::GetSafePath(WPath)); oldpos = pos + 2; } else if (cs[px] == '#') { // file name From 37714652b2a19cc1bee1fd5ccf1798b1eb44ff49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Schplurtz=20le=20D=C3=A9boulonn=C3=A9?= Date: Thu, 3 Dec 2020 09:57:07 +0100 Subject: [PATCH 3/4] change version to 0.5.13 --- CHANGELOG | 2 ++ Doxyfile | 2 +- VERSION | 2 +- incron.conf.5 | 2 +- incron.h | 2 +- incrond.8 | 2 +- incrontab.1 | 2 +- incrontab.5 | 2 +- 8 files changed, 9 insertions(+), 7 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index ddc6e0b..5b094bd 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +0.5.12 2020-12-03 +* fix SEGV when directory are created in watched directories 0.5.12 2015-02-01 * added recursive directory watching * added configuration parameters: recursive, dotdirs and loopable diff --git a/Doxyfile b/Doxyfile index 759a4bc..b905a6c 100644 --- a/Doxyfile +++ b/Doxyfile @@ -31,7 +31,7 @@ PROJECT_NAME = incron # This could be handy for archiving the generated documentation or # if some version control system is used. -PROJECT_NUMBER = 0.5.12 +PROJECT_NUMBER = 0.5.13 # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. diff --git a/VERSION b/VERSION index 9d6c175..964783a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.5.12 +0.5.13 diff --git a/incron.conf.5 b/incron.conf.5 index 65bcdb7..5b954ca 100644 --- a/incron.conf.5 +++ b/incron.conf.5 @@ -1,4 +1,4 @@ -.TH "incron.conf" "5" "0.5.12" "Lukas Jelinek" "incron documentation" +.TH "incron.conf" "5" "0.5.13" "Lukas Jelinek" "incron documentation" .SH "NAME" /etc/incron.conf \- main config file for inotify cron (incron) .SH "DESCRIPTION" diff --git a/incron.h b/incron.h index 385ad0f..2ab0d86 100644 --- a/incron.h +++ b/incron.h @@ -28,7 +28,7 @@ #define INCRONTAB_NAME "incrontab" /// Application version (release) -#define INCRON_VERSION "0.5.12" +#define INCRON_VERSION "0.5.13" /// Default configuration file #define INCRON_CONFIG "/etc/incron.conf" diff --git a/incrond.8 b/incrond.8 index cffe80e..f613975 100644 --- a/incrond.8 +++ b/incrond.8 @@ -1,4 +1,4 @@ -.TH "incrond" "8" "0.5.12" "Lukas Jelinek" "incron documentation" +.TH "incrond" "8" "0.5.13" "Lukas Jelinek" "incron documentation" .SH "NAME" incrond \- inotify cron (incron) daemon diff --git a/incrontab.1 b/incrontab.1 index e767703..40aaa75 100644 --- a/incrontab.1 +++ b/incrontab.1 @@ -1,4 +1,4 @@ -.TH "incrontab" "1" "0.5.12" "Lukas Jelinek" "incron documentation" +.TH "incrontab" "1" "0.5.13" "Lukas Jelinek" "incron documentation" .SH "NAME" incrontab \- table manipulator for inotify cron (incron) .SH "SYNOPSIS" diff --git a/incrontab.5 b/incrontab.5 index d94ebe7..b216845 100644 --- a/incrontab.5 +++ b/incrontab.5 @@ -1,4 +1,4 @@ -.TH "incrontab" "5" "0.5.12" "Lukas Jelinek" "incron documentation" +.TH "incrontab" "5" "0.5.13" "Lukas Jelinek" "incron documentation" .SH "NAME" incrontab \- tables for driving inotify cron (incron) .SH "DESCRIPTION" From 4d42fed075a55a9ba7ace3d9fef88ebbdb3ba566 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Schplurtz=20le=20D=C3=A9boulonn=C3=A9?= Date: Thu, 3 Dec 2020 10:18:24 +0100 Subject: [PATCH 4/4] make debian version the same as incron itself --- debian/changelog | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/debian/changelog b/debian/changelog index ccd80f8..5025579 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +incron (0.5.13-1) unstable; urgency=medium + + * fixed bug #36 where incrond could die with SEGV. + (Closes: #973927) + (Closes: #947425) + + -- Schplurtz le Déboulonné Thu, 03 Dec 2020 10:11:32 +0100 + incron (0.5.12-1) unstable; urgency=medium * linked homepage, watch-file and bugtracker to changes upstream on github