[hackers] [sbase] find: estrdup before basename || Evan Gates

From: <git_AT_suckless.org>
Date: Tue, 27 Dec 2016 15:04:01 +0100 (CET)

commit 0b27c0c9a08ac4fd23a8753f2a3ba8672cd94497
Author: Evan Gates <evan.gates_AT_gmail.com>
AuthorDate: Wed Oct 5 15:37:34 2016 -0700
Commit: Laslo Hunhold <dev_AT_frign.de>
CommitDate: Tue Dec 27 12:37:57 2016 +0100

    find: estrdup before basename
    
    "The basename() function may modify the string pointed to by path..."
    Thanks POSIX
    
    Laslo: Changed the style a bit

diff --git a/find.c b/find.c
index 5f75735..fb6f21e 100644
--- a/find.c
+++ b/find.c
_AT_@ -229,7 +229,14 @@ static struct {
 static int
 pri_name(struct arg *arg)
 {
- return !fnmatch((char *)arg->extra.p, basename(arg->path), 0);
+ int ret;
+ char *path;
+
+ path = estrdup(arg->path);
+ ret = !fnmatch((char *)arg->extra.p, basename(path), 0);
+ free(path);
+
+ return ret;
 }
 
 static int
Received on Tue Dec 27 2016 - 15:04:01 CET

This archive was generated by hypermail 2.3.0 : Tue Dec 27 2016 - 15:12:38 CET