Extend workaround for TCP fragmentation

Instead of checking via uname for Linux this commit does a check
whether the outcome for an external printf is what is expected. This
makes it more compatible e.g. with OpenBSD which surprisingly works
similar like the GNU counterpart.

Also it checks all external printfs installed wther it's the
"right one" to use. Previously it stopped just at the first one
and if this was "wrong", bash's printf was used.
This commit is contained in:
Dirk 2018-10-02 23:04:02 +02:00
parent b22e0d08fd
commit 1b52834dfc

View File

@ -267,6 +267,7 @@ declare -r UA_SNEAKY="Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Fi
########### Initialization part, further global vars just being declared here ########### Initialization part, further global vars just being declared here
# #
PRINTF="" # which external printf to use
IKNOW_FNAME=false IKNOW_FNAME=false
FIRST_FINDING=true # is this the first finding we are outputting to file? FIRST_FINDING=true # is this the first finding we are outputting to file?
JSONHEADER=true # include JSON headers and footers in HTML file, if one is being created JSONHEADER=true # include JSON headers and footers in HTML file, if one is being created
@ -1114,7 +1115,6 @@ debugme() {
} }
hex2dec() { hex2dec() {
#/usr/bin/printf -- "%d" 0x"$1"
echo $((16#$1)) echo $((16#$1))
} }
@ -15440,13 +15440,21 @@ check_bsd_mount() {
# This sets the PRINTF command for writing into TCP sockets. It is needed because # This sets the PRINTF command for writing into TCP sockets. It is needed because
# The shell builtin printf flushes the write buffer at every \n, ("\x0a") which # The shell builtin printf flushes the write buffer at every \n, ("\x0a") which
# in turn means a new TCP fragment. That causes a slight performance penalty and # in turn means a new TCP fragment. That causes a slight performance penalty and
# and some F5s to hiccup, see #1113. Unfortunately this can be only used under # and some F5s to hiccup, see #1113. Unfortunately this can be used only with GNU's
# Linux, see #1134. A better solution needs to follow # and OpenBSD's /usr/bin/printf -- FreeBSD + OS X can't do this.
# A better solution needs to follow.
# #
choose_printf() { choose_printf() {
PRINTF="$(type -P printf)" local p ptf
if [[ -n "$PRINTF" ]] && [[ "$SYSTEM" == Linux ]]; then
return 0 ptf="$(type -aP printf)"
if [[ -n "$ptf" ]]; then
for p in $ptf; do
if $p "\xc0\x14\xc0\xff\xee" | hexdump -C | grep -q 'c0 14 c0 ff ee'; then
PRINTF=$p
return 0
fi
done
fi fi
if type -t printf >/dev/null; then if type -t printf >/dev/null; then
PRINTF=printf PRINTF=printf
@ -15610,7 +15618,7 @@ os constraint: $SYSTEM2
shellopts: $SHELLOPTS shellopts: $SHELLOPTS
printf: $PRINTF printf: $PRINTF
$($OPENSSL version -a) $($OPENSSL version -a 2>/dev/null)
OSSL_VER_MAJOR: $OSSL_VER_MAJOR OSSL_VER_MAJOR: $OSSL_VER_MAJOR
OSSL_VER_MINOR: $OSSL_VER_MINOR OSSL_VER_MINOR: $OSSL_VER_MINOR
OSSL_VER_APPENDIX: $OSSL_VER_APPENDIX OSSL_VER_APPENDIX: $OSSL_VER_APPENDIX
@ -17860,13 +17868,13 @@ lets_roll() {
set_color_functions set_color_functions
maketempf maketempf
find_openssl_binary find_openssl_binary
choose_printf
prepare_debug ; stopwatch parse prepare_debug ; stopwatch parse
prepare_arrays ; stopwatch prepare_arrays prepare_arrays ; stopwatch prepare_arrays
mybanner mybanner
check_proxy check_proxy
check4openssl_oldfarts check4openssl_oldfarts
check_bsd_mount check_bsd_mount
choose_printf
if "$do_display_only"; then if "$do_display_only"; then
prettyprint_local "$PATTERN2SHOW" prettyprint_local "$PATTERN2SHOW"