The branch main has been updated by wosch:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=f8b632fb046de18f82705eddd5a11f91d54036df

commit f8b632fb046de18f82705eddd5a11f91d54036df
Author:     Wolfram Schneider <wo...@freebsd.org>
AuthorDate: 2025-07-21 07:23:45 +0000
Commit:     Wolfram Schneider <wo...@freebsd.org>
CommitDate: 2025-07-21 07:23:45 +0000

    man.sh: avoid endless loop
    
    limit the number of .so includes to a value of 32 instead of infinity.
    
    PR: 287037
    Differential Revision: https://reviews.freebsd.org/D51412
---
 usr.bin/man/man.sh | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/usr.bin/man/man.sh b/usr.bin/man/man.sh
index ec20fc813bf4..18595042da5f 100755
--- a/usr.bin/man/man.sh
+++ b/usr.bin/man/man.sh
@@ -313,6 +313,8 @@ manpath_warnings() {
 # redirected to another source file.
 man_check_for_so() {
        local IFS line tstr
+       local counter_so=0
+       local counter_so_limit=32
 
        unset IFS
        if [ -n "$catpage" ]; then
@@ -320,13 +322,16 @@ man_check_for_so() {
        fi
 
        # We need to loop to accommodate multiple .so directives.
-       while true
+       while [ $counter_so -lt $counter_so_limit ]
        do
+               counter_so=$((counter_so + 1))
+
                line=$($cattool "$manpage" 2>/dev/null | grep -E -m1 -v 
'^\.\\"[ ]*|^[ ]*$')
                case "$line" in
                '.so /'*) break ;; # ignore absolute path
                '.so '*) trim "${line#.so}"
-                       decho "$manpage includes $tstr"
+                       decho "$manpage includes $tstri level=$counter_so"
+
                        # Glob and check for the file.
                        if ! check_man "$1/$tstr" ""; then
                                decho "  Unable to find $tstr"
@@ -337,6 +342,10 @@ man_check_for_so() {
                esac
        done
 
+       if [ $counter_so -ge $counter_so_limit ]; then
+               decho ".so include limit of $counter_so_limit reached, stop"
+       fi
+
        return 0
 }
 

Reply via email to