From: Dmitry Bogatov Date: Sat, 4 Mar 2017 21:13:38 +0300 Subject: [PATCH] Fix segfault with csv output when filename contains comma Double `csv_escape()'ing filename is logic error, but root of the problem was that passing `csv' buffer back into `csv_escape()' caused endless loop over `static char csv[MAXLEN]', and buffer overflow. --- src/inotifywait.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/inotifywait.c b/src/inotifywait.c index 98aadd4..6e17007 100644 --- a/src/inotifywait.c +++ b/src/inotifywait.c @@ -119,7 +119,7 @@ void validate_format( char * fmt ) { void output_event_csv( struct inotify_event * event ) { char *filename = csv_escape(inotifytools_filename_from_wd(event->wd)); if (filename != NULL) - printf("%s,", csv_escape(filename)); + printf("%s,", filename); printf("%s,", csv_escape( inotifytools_event_to_str( event->mask ) ) ); if ( event->len > 0 )