From f4c2ff2f29a17a5916e9bf642240abb5f4fc190a Mon Sep 17 00:00:00 2001 From: okan Date: Fri, 2 Feb 2018 13:27:25 +0000 Subject: Simplification; use asprintf where appropriate now. --- search.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'search.c') diff --git a/search.c b/search.c index fde91af..ff17492 100644 --- a/search.c +++ b/search.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: search.c,v 1.68 2018/01/23 13:51:39 okan Exp $ + * $OpenBSD: search.c,v 1.69 2018/02/02 13:27:25 okan Exp $ */ #include @@ -162,12 +162,11 @@ static void match_path_type(struct menu_q *resultq, char *search, int flag) { struct menu *mi; - char pattern[PATH_MAX]; + char *pattern; glob_t g; int i; - (void)strlcpy(pattern, search, sizeof(pattern)); - (void)strlcat(pattern, "*", sizeof(pattern)); + xasprintf(&pattern, "%s*", search); if (glob(pattern, GLOB_MARK, NULL, &g) != 0) return; for (i = 0; i < g.gl_pathc; i++) { @@ -178,6 +177,7 @@ match_path_type(struct menu_q *resultq, char *search, int flag) TAILQ_INSERT_TAIL(resultq, mi, resultentry); } globfree(&g); + free(pattern); } void -- cgit v1.2.3-2-gb3c3