summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillermo E. Martinez via Libabigail <libabigail@sourceware.org>2022-04-25 12:01:23 -0500
committerDodji Seketeli <dodji@redhat.com>2022-05-02 17:29:11 +0200
commitfecdcac890e35e7704710803f17ba4b04692786e (patch)
tree8f18c370f84b0064120cfa817885af9787cc0d90
parentFix typo in abipkgdiff manpage (diff)
downloadlibabigail-fecdcac890e35e7704710803f17ba4b04692786e.tar.gz
libabigail-fecdcac890e35e7704710803f17ba4b04692786e.tar.bz2
libabigail-fecdcac890e35e7704710803f17ba4b04692786e.tar.xz
tools-utils: `entry_of_file_with_name' returns incorrect result
entry_of_file_with_name uses `string_ends_with' to test if the filename given in the `fts_path' member of `FTSENT' matches the `fname' argument. This result is not correct when in the current directory there are file with names: "./rmdir-xyx", "./dir-xyz" it returns true for both files, this patch fixes this ambiguity by using `basename' instead of `string_ends_with'. * src/abg-tools-utils.cc (entry_of_file_with_name): Replace call `string_ends_with' by `basename'. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
-rw-r--r--src/abg-tools-utils.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/abg-tools-utils.cc b/src/abg-tools-utils.cc
index e94c3003..1f0f6fa8 100644
--- a/src/abg-tools-utils.cc
+++ b/src/abg-tools-utils.cc
@@ -2141,8 +2141,8 @@ entry_of_file_with_name(const FTSENT *entry,
2141 || entry->fts_info == FTS_NS) 2141 || entry->fts_info == FTS_NS)
2142 return false; 2142 return false;
2143 2143
2144 string fpath = entry->fts_path; 2144 string fpath = ::basename(entry->fts_path);
2145 if (string_ends_with(fpath, fname)) 2145 if (fpath == fname)
2146 return true; 2146 return true;
2147 return false; 2147 return false;
2148} 2148}