From 7740e52c1687e1330439431ad4c7d32632da3001 Mon Sep 17 00:00:00 2001 From: X512 Date: Fri, 24 Jan 2020 08:38:57 +0900 Subject: [PATCH] TextSearch: fix passing search string to grep MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix proposed by phoudoin. Fixes #15650. Change-Id: Ie7177aaa39ff593445506983cb0725b75ca7bc7d Reviewed-on: https://review.haiku-os.org/c/haiku/+/2149 Reviewed-by: Jérôme Duval --- src/apps/text_search/Grepper.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/apps/text_search/Grepper.cpp b/src/apps/text_search/Grepper.cpp index e03bafc3b1..6f89456f4b 100644 --- a/src/apps/text_search/Grepper.cpp +++ b/src/apps/text_search/Grepper.cpp @@ -270,7 +270,10 @@ Grepper::_RunnerThread() if (! fCaseSensitive) argv[argc++] = "-i"; if (! fRegularExpression) - argv[argc++] = "-F"; // no a regexp: force fixed string, + argv[argc++] = "-F"; // no a regexp: force fixed string, + // Add double dash argument to tell grep + // it's the end of commands options + argv[argc++] = "--"; argv[argc++] = fPattern; argv[argc] = NULL; @@ -420,7 +423,7 @@ Grepper::_RunnerThread() if (strcmp(fileName, currentFileName) != 0) { fTarget.SendMessage(&message); - strncpy(currentFileName, fileName, + strncpy(currentFileName, fileName, sizeof(currentFileName)); message.MakeEmpty();