diff --git a/CHANGES b/CHANGES index 5fb94ee..9fdec1b 100644 --- a/CHANGES +++ b/CHANGES @@ -79,6 +79,14 @@ Porting: Socat failed to build on platforms without flock() function (AIX, Solaris) due to a missing guard. + Newer Linux distributions do not provide libwrap: do not leave unused + variable. + + Newer Linux distributions deprecate usleep, replace it. + + OpenSSL-3 loudly deprecates some functions or macros, replace a first + bunch of them. + Testing: test.sh produces file results.txt with columns of test numbers, names, and results. @@ -92,6 +100,8 @@ Testing: Added a developer test that overwrites malloc'ed memory with non-zeros. + Newer Linux distributions now deprecate usleep; replaced it in test.sh + ####################### V 1.8.0.2: Security: diff --git a/test.sh b/test.sh index 6475a7b..f1500e6 100755 --- a/test.sh +++ b/test.sh @@ -112,6 +112,17 @@ MICROS=${S}${uS} MICROS=${MICROS##0000}; MICROS=${MICROS##00}; MICROS=${MICROS##0} # changed below again +divide_uint_by_1000000 () { + x=$1 + if [ ${#x} -ge 7 ]; then + echo ${x%??????}.${x: -6}; + else + y=000000$x; + f=${y: -6}; + echo 0.$f; + fi +} + _MICROS=$((MICROS+999999)); SECONDs="${_MICROS%??????}" [ -z "$SECONDs" ] && SECONDs=0 [ "$DEFS" ] && echo "SECONDs=\"$SECONDs\"" >&2 @@ -193,7 +204,7 @@ PATH=$PATH:/sbin # RHEL6:ip case "$0" in */*) PATH="${0%/*}:$PATH" esac -PATH=.:$PATH # for usleep,relsleep +PATH=.:$PATH # for relsleep [ "$DEFS" ] && echo "PATH=\"$PATH\"" >&2 #OPENSSL_RAND="-rand /dev/egd-pool" @@ -308,47 +319,6 @@ tolower () { esac } -if ! which usleep >/dev/null 2>&1; then -cat >usleep <<EOF -#! /usr/bin/env bash -# temporary script from Socat test.sh: -# sleep for a number of µs -u=\$1 -l=\${#u} -i=0 -[ "\$l" -gt 6 ] && i=\${u%??????} -u0=000000\$u -s=\${i}.\${u0: -6:6}; -#echo \$s -sleep \$s -EOF -chmod a+x usleep -fi - -# precision sleep; takes seconds with fractional part; sleep does this on all test platforms -if false; then -psleep () { - local T="$1" - [ "$T" = 0 ] && T=0.000002 - #$SOCAT -T "$T" PIPE PIPE 2>/dev/null - sleep "$T" -} -# time in microseconds to wait in some situations -if ! type usleep >/dev/null 2>&1 || - usleep 0 2>&1 |grep -q deprecated; then - usleep () { - local n="$1" - case "$n" in - *???????) S="${n%??????}"; uS="${n:${#n}-6}" ;; - *) S=0; uS="00000$n"; uS="${uS:${#uS}-6}" ;; - esac - #$SOCAT -T "$S.$uS" PIPE PIPE 2>/dev/null - sleep "$S.$uS" - } -fi -#USLEEP=usleep -fi - # calculate the time i*MICROS, output as float number for us with -t reltime () { local n="$1" @@ -361,11 +331,12 @@ reltime () { echo "$S.$uS" } -# A sleep with configurable clocking ($vat_t) +# A sleep with configurable clocking ($val_t) # val_t should be at least the time that a Socat invocation, no action, and # termination takes relsleep () { - usleep $(($1*MICROS)) + #sleep $(($1*MICROS/1000000)) + sleep $(divide_uint_by_1000000 $(($1*MICROS)) ) } cat >relsleep <<-'EOF' diff --git a/xio-openssl.c b/xio-openssl.c index 1278bf4..006e378 100644 --- a/xio-openssl.c +++ b/xio-openssl.c @@ -702,7 +702,7 @@ int _xioopen_openssl_listen(struct single *sfd, const char *opt_commonname, SSL_CTX *ctx, int level) { - char error_string[120]; + char error_string[256]; unsigned long err; int errint, ret; @@ -764,7 +764,7 @@ int _xioopen_openssl_listen(struct single *sfd, while (err = ERR_get_error()) { ERR_error_string_n(err, error_string, sizeof(error_string)); Msg4(level, "SSL_accept(): %s / %s / %s / %s", error_string, - ERR_lib_error_string(err), ERR_func_error_string(err), + ERR_lib_error_string(err), error_string, ERR_reason_error_string(err)); } /* Msg1(level, "SSL_accept(): %s", ERR_error_string(e, buf));*/ @@ -1976,7 +1976,7 @@ static int xioSSL_set_fd(struct single *sfd, int level) { should not retry for any reason. */ static int xioSSL_connect(struct single *sfd, const char *opt_commonname, bool opt_ver, int level) { - char error_string[120]; + char error_string[256]; int errint, status, ret; unsigned long err; @@ -2012,7 +2012,7 @@ static int xioSSL_connect(struct single *sfd, const char *opt_commonname, while (err = ERR_get_error()) { ERR_error_string_n(err, error_string, sizeof(error_string)); Msg4(level, "SSL_connect(): %s / %s / %s / %s", error_string, - ERR_lib_error_string(err), ERR_func_error_string(err), + ERR_lib_error_string(err), error_string, ERR_reason_error_string(err)); } } @@ -2037,7 +2037,7 @@ static int xioSSL_connect(struct single *sfd, const char *opt_commonname, /* on result < 0: errno is set (at least to EIO) */ ssize_t xioread_openssl(struct single *pipe, void *buff, size_t bufsiz) { unsigned long err; - char error_string[120]; + char error_string[256]; int _errno = EIO; /* if we have no better idea about nature of error */ int errint, ret; @@ -2072,7 +2072,7 @@ ssize_t xioread_openssl(struct single *pipe, void *buff, size_t bufsiz) { while (err = ERR_get_error()) { ERR_error_string_n(err, error_string, sizeof(error_string)); Error4("SSL_read(): %s / %s / %s / %s", error_string, - ERR_lib_error_string(err), ERR_func_error_string(err), + ERR_lib_error_string(err), error_string, ERR_reason_error_string(err)); } } @@ -2098,7 +2098,7 @@ ssize_t xiopending_openssl(struct single *pipe) { /* on result < 0: errno is set (at least to EIO) */ ssize_t xiowrite_openssl(struct single *pipe, const void *buff, size_t bufsiz) { unsigned long err; - char error_string[120]; + char error_string[256]; int _errno = EIO; /* if we have no better idea about nature of error */ int errint, ret; @@ -2131,7 +2131,7 @@ ssize_t xiowrite_openssl(struct single *pipe, const void *buff, size_t bufsiz) { while (err = ERR_get_error()) { ERR_error_string_n(err, error_string, sizeof(error_string)); Error4("SSL_write(): %s / %s / %s / %s", error_string, - ERR_lib_error_string(err), ERR_func_error_string(err), + ERR_lib_error_string(err), error_string, ERR_reason_error_string(err)); } } diff --git a/xio-socket.c b/xio-socket.c index dbbde71..c798598 100644 --- a/xio-socket.c +++ b/xio-socket.c @@ -1679,7 +1679,9 @@ int xiocheckrange(union sockaddr_union *sa, struct xiorange *range) { int xiocheckpeer(xiosingle_t *sfd, union sockaddr_union *pa, union sockaddr_union *la) { char infobuff[256]; +#if (WITH_TCP || WITH_UDP) && WITH_LIBWRAP int result; +#endif #if WITH_IP4 || WITH_IP6 if (sfd->para.socket.dorange) {