public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Bug 31793 - tools-utils: Avoid endless loop in is_regular_file for directories
@ 2024-05-31 16:26 Dodji Seketeli
  0 siblings, 0 replies; only message in thread
From: Dodji Seketeli @ 2024-05-31 16:26 UTC (permalink / raw)
  To: libabigail; +Cc: Claudiu Zissulescu Ianculescu

Hello,

Claudio Claudiu Zissulescu Ianculescu reported that 'abidw --linux-tree /some/linux/kernel/tree'
is crashing: https://sourceware.org/bugzilla/show_bug.cgi?id=31793.

This due to the fact that when is_regular_file is given a directory, it
loops endlessly.  Oops.

Fixed thus.

	* src/abg-tools-utils.cc (is_regular_file): Loop on symbolic links
	only.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Applying to the master branch.
---
 src/abg-tools-utils.cc | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/abg-tools-utils.cc b/src/abg-tools-utils.cc
index 6d6ab054..95bd0be5 100644
--- a/src/abg-tools-utils.cc
+++ b/src/abg-tools-utils.cc
@@ -416,9 +416,12 @@ is_regular_file(const string& path)
   if (S_ISREG(st.st_mode))
     return true;
 
-  string symlink_target_path;
-  if (maybe_get_symlink_target_file_path(path, symlink_target_path))
-    return is_regular_file(symlink_target_path);
+  if (S_ISLNK(st.st_mode))
+    {
+      string symlink_target_path;
+      if (maybe_get_symlink_target_file_path(path, symlink_target_path))
+	return is_regular_file(symlink_target_path);
+    }
 
   return false;
 }
-- 
2.43.0


-- 
		Dodji


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-05-31 16:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-31 16:26 [PATCH] Bug 31793 - tools-utils: Avoid endless loop in is_regular_file for directories Dodji Seketeli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).