"The basename() function may modify the string pointed to by path..."
Thanks POSIX.
From e4777a57d315df539517cf24bcb5a52659a93a77 Mon Sep 17 00:00:00 2001
From: Evan Gates <evan.ga...@gmail.com>
Date: Mon, 3 Oct 2016 14:58:35 -0700
Subject: [PATCH] find: copy path before using basename

"The basename() function may modify the string pointed to by path..."
Thanks POSIX.
---
 find.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/find.c b/find.c
index ad0c731..cf26262 100644
--- a/find.c
+++ b/find.c
@@ -228,7 +228,9 @@ static struct {
 static int
 pri_name(struct arg *arg)
 {
-       return !fnmatch((char *)arg->extra.p, basename(arg->path), 0);
+       char path[strlen(arg->path)+1];
+       strcpy(path, arg->path);
+       return !fnmatch((char *)arg->extra.p, path, 0);
 }
 
 static int
-- 
2.10.0

Reply via email to