2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-22 01:49:11 +00:00

Fix potential infinite loop when trying to format long lines.

This commit is contained in:
Todd C. Miller 2022-01-25 12:10:36 -07:00
parent 5f45fd907b
commit ada7d43825

View File

@ -68,8 +68,12 @@ sub fmt_depend {
if ($off != 0) { if ($off != 0) {
$ret .= ' ' x $indent; $ret .= ' ' x $indent;
$pos = rindex($deps, ' ', $off + 80 - $indent - 2); $pos = rindex($deps, ' ', $off + 80 - $indent - 2);
if ($pos <= $off) {
# No space found within 78 columns, check beyond
$pos = index($deps, ' ', $off + 80 - $indent - 2);
}
} else { } else {
$pos = rindex($deps, ' ', $off + 78); $pos = rindex($deps, ' ', 78);
} }
$ret .= substr($deps, $off, $pos - $off) . " \\\n"; $ret .= substr($deps, $off, $pos - $off) . " \\\n";
$off = $pos + 1; $off = $pos + 1;