Bug 31793 - tools-utils: Avoid endless loop in is_regular_file for directories
Commit Message
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(-)
@@ -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;
}