Using `entry_of_file_with_name' returns incorrect result

Message ID
State New
Series Using `entry_of_file_with_name' returns incorrect result |

Commit Message

Guillermo E. Martinez April 25, 2022, 5:01 p.m. UTC
  Hello libabigail team,

This patch corrects the returning value for `entry_of_file_with_name'
function when more than one file in a given directory has a same suffix,

Comments will be appreciated.

Kind Regards,

Function `entry_of_file_with_name' uses `string_ends_with' to test if a
given `fts_path' member of `FTSENT' structure match with `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 using `basename' instead.

	* src/ (entry_of_file_with_name): Replace
	call `string_ends_with' by `basename'.
 src/ | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)


Dodji Seketeli May 2, 2022, 3:29 p.m. UTC | #1
Hello Guillermo,

"Guillermo E. Martinez via Libabigail" <> a


> 	* src/ (entry_of_file_with_name): Replace
> 	call `string_ends_with' by `basename'.

Applied to master, thanks!




diff --git a/src/ b/src/
index e94c3003..1f0f6fa8 100644
--- a/src/
+++ b/src/
@@ -2141,8 +2141,8 @@  entry_of_file_with_name(const FTSENT *entry,
       || entry->fts_info == FTS_NS)
     return false;
-  string fpath = entry->fts_path;
-  if (string_ends_with(fpath, fname))
+  string fpath = ::basename(entry->fts_path);
+  if (fpath == fname)
     return true;
   return false;