--- pf-badhost.sh.orig	Wed Jul  1 00:00:00 2020
+++ pf-badhost.sh	Fri Jul 10 21:37:55 2020
@@ -14,7 +14,7 @@
 # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 
 # PERFORMANCE OF THIS SOFTWARE.
 
-# Version 0.4 "Violence Begets Violence" -- Released July 1st 2020
+# Version 0.4p0 "Violence Begets Violence" -- Released July 10th 2020
 
 # In loving memory of Ron Sather
 
@@ -94,14 +94,14 @@
 # Validates IPv4 addresses (can pull addresses from arbitrarily formatted text, thanks to "grep -o"
 parse_v4() {
 	# Replace use of grep with ripgrep or GNU grep for a large performance increase
-	nice grep -E -o "((25[0-5]|(2[0-4]|1{0,1}[[:digit:]]){0,1}[[:digit:]])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[[:digit:]]){0,1}[[:digit:]])(/[1-9]|/[1-2][[:digit:]]|/3[0-2])?"
+	nice grep -E -o '((25[0-5]|(2[0-4]|1{0,1}[[:digit:]]){0,1}[[:digit:]])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[[:digit:]]){0,1}[[:digit:]])(/(3[0-2]|[1-2][[:digit:]]|[1-9]))?'
 }
 
 # Validates IPv6 addresses (Addresses must be RFC-5952 Compliant and have one address per line)
 # Many IPv6 address lists require a preprocessor to format the lists/addresses correctly for validation 
 parse_v6() {
 	# Replace use of grep with ripgrep or GNU grep for a large performance increase
-	tr -cd '[:alnum:]:./\n' | nice grep -E -x '(([[:xdigit:]]{1,4}:){7,7}[[:xdigit:]]{1,4}|([[:xdigit:]]{1,4}:){1,7}:|([[:xdigit:]]{1,4}:){1,6}:[[:xdigit:]]{1,4}|([[:xdigit:]]{1,4}:){1,5}(:[[:xdigit:]]{1,4}){1,2}|([[:xdigit:]]{1,4}:){1,4}(:[[:xdigit:]]{1,4}){1,3}|([[:xdigit:]]{1,4}:){1,3}(:[[:xdigit:]]{1,4}){1,4}|([[:xdigit:]]{1,4}:){1,2}(:[[:xdigit:]]{1,4}){1,5}|[[:xdigit:]]{1,4}:((:[[:xdigit:]]{1,4}){1,6})|:((:[[:xdigit:]]{1,4}){1,7}|:)|[fF][eE]80:(:[[:xdigit:]]{0,4}){0,4}%[[:alnum:]]{1,}|::([fF]{4}(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[[:digit:]]){0,1}[[:digit:]])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[[:digit:]]){0,1}[[:digit:]])|([[:xdigit:]]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[[:digit:]]){0,1}[[:digit:]])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[[:digit:]]){0,1}[[:digit:]]))(/[1-9]|/[1-9][[:digit:]]|/1[0-1][[:digit:]]|/12[0-8])?'
+	tr -cd '[:alnum:]:./\n' | nice grep -E -x '(([[:xdigit:]]{1,4}:){7,7}[[:xdigit:]]{1,4}|([[:xdigit:]]{1,4}:){1,7}:|([[:xdigit:]]{1,4}:){1,6}:[[:xdigit:]]{1,4}|([[:xdigit:]]{1,4}:){1,5}(:[[:xdigit:]]{1,4}){1,2}|([[:xdigit:]]{1,4}:){1,4}(:[[:xdigit:]]{1,4}){1,3}|([[:xdigit:]]{1,4}:){1,3}(:[[:xdigit:]]{1,4}){1,4}|([[:xdigit:]]{1,4}:){1,2}(:[[:xdigit:]]{1,4}){1,5}|[[:xdigit:]]{1,4}:((:[[:xdigit:]]{1,4}){1,6})|:((:[[:xdigit:]]{1,4}){1,7}|:)|[fF][eE]80:(:[[:xdigit:]]{0,4}){0,4}%[[:alnum:]]{1,}|::([fF]{4}(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[[:digit:]]){0,1}[[:digit:]])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[[:digit:]]){0,1}[[:digit:]])|([[:xdigit:]]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[[:digit:]]){0,1}[[:digit:]])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[[:digit:]]){0,1}[[:digit:]]))(/(12[0-8]|1[0-1][[:digit:]]|[1-9][[:digit:]]{0,1}))?'
 }
 
 
@@ -150,39 +150,39 @@
 	# If aggregate{6} utility not found, use Perl function
 	if [ "$agg4" = "0" ] && [ "$agg6" = "0" ] && [ "$perl_exist" = "1" ]; then
 		printf '\nFalling back to pure Perl aggregator...\n\n'
-		find "$tmpdir" -type f -exec cat {} + | parse_v4 | sub_aggr_perl > "$v4list" || tmp_file_abort
+		find "$tmpdir" -type f -print0 | xargs -0 cat | parse_v4 | sub_aggr_perl > "$v4list" || tmp_file_abort
 	fi
 	# aggregate C utility
 	if [ "$agg4" = "1" ] && [ "$agg6" = "0" ]; then
-		find "$tmpdir" -type f -exec cat {} + | parse_v4 | sub_aggr_c > "$v4list" || tmp_file_abort
+		find "$tmpdir" -type f -print0 | xargs -0 cat | parse_v4 | sub_aggr_c > "$v4list" || tmp_file_abort
 	fi
 	# Use aggregate6 IPv4 support if C based aggregate util not found
 	if [ "$agg4" = "0" ] && [ "$agg6" = "1" ]; then
-		find "$tmpdir" -type f -exec cat {} + | parse_v4 | sub_aggr_py > "$v4list" || tmp_file_abort
+		find "$tmpdir" -type f -print0 | xargs -0 cat | parse_v4 | sub_aggr_py > "$v4list" || tmp_file_abort
 	fi
 	# Prefer the C based 'aggregate' util over the Python based 'aggregate6' util
 	if [ "$agg4" = "1" ] && [ "$agg6" = "1" ]; then
-		find "$tmpdir" -type f -exec cat {} + | parse_v4 | sub_aggr_c > "$v4list" || tmp_file_abort
+		find "$tmpdir" -type f -print0 | xargs -0 cat | parse_v4 | sub_aggr_c > "$v4list" || tmp_file_abort
 	fi
 
 	## IPv6 Logic
 	# If IPv6 is enabled and 'aggregate6' is installed, then we can aggregate IPv6 prefixes too!
 	if [ "$IPv6" = "1" ] && [ "$agg6" = "1" ]; then
-		find "$tmpdir" -type f -exec cat {} + | parse_v6 | sub_aggr6_py > "$v6list" || tmp_file_abort
+		find "$tmpdir" -type f -print0 | xargs -0 cat | parse_v6 | sub_aggr6_py > "$v6list" || tmp_file_abort
 	fi
 	# If IPv6=1 but aggregate6 util not found...
 	if [ "$IPv6" = "1" ] && [ "$agg6" = "0" ]; then
 		echo "aggregate6 utility not found, unable to aggregate IPv6 addresses..."
-		find "$tmpdir" -type f -exec cat {} + | parse_v6 | tr '[:upper:]' '[:lower:]' | sort -Vu > "$v6list" || tmp_file_abort
+		find "$tmpdir" -type f -print0 | xargs -0 cat | parse_v6 | tr '[:upper:]' '[:lower:]' | sort -Vu > "$v6list" || tmp_file_abort
 	fi
 }
 
 noopt() {
 	if [ "$IPv6" = "1" ]; then
-		find "$tmpdir" -type f -exec cat {} + | parse_v4 | sort -Vu > "$v4list" || tmp_file_abort
-		find "$tmpdir" -type f -exec cat {} + | parse_v6 | tr '[:upper:]' '[:lower:]' | sort -Vu > "$v6list" || tmp_file_abort
+		find "$tmpdir" -type f -print0 | xargs -0 cat | parse_v4 | sort -Vu > "$v4list" || tmp_file_abort
+		find "$tmpdir" -type f -print0 | xargs -0 cat | parse_v6 | tr '[:upper:]' '[:lower:]' | sort -Vu > "$v6list" || tmp_file_abort
 	else
-		find "$tmpdir" -type f -exec cat {} + | parse_v4 | sort -Vu > "$v4list" || tmp_file_abort
+		find "$tmpdir" -type f -print0 | xargs -0 cat | parse_v4 | sort -Vu > "$v4list" || tmp_file_abort
 	fi
 }
 
