From 6fd570f81f277178f28fac89d6b6937d1387b3ad Mon Sep 17 00:00:00 2001 From: John Hood Date: Sun, 17 Jan 2016 23:18:05 -0500 Subject: [PATCH] Various fixes for Illumos Hipster 20151003. --- src/crypto/byteorder.h | 20 ++++++------- src/crypto/crypto.cc | 3 ++ src/tests/e2e-test | 3 -- src/tests/emulation-ascii-iso-8859.test | 33 ++++++++++----------- src/tests/emulation-wrap-across-frames.test | 33 ++++++++++----------- src/tests/prediction-unicode.test | 33 ++++++++++----------- src/tests/server-network-timeout.test | 2 +- 7 files changed, 62 insertions(+), 65 deletions(-) diff --git a/src/crypto/byteorder.h b/src/crypto/byteorder.h index e5f9baa..bc91cc2 100644 --- a/src/crypto/byteorder.h +++ b/src/crypto/byteorder.h @@ -72,14 +72,14 @@ inline uint64_t htobe64( uint64_t x ) { uint8_t xs[ 8 ] = { - ( x >> 56 ) & 0xFF, - ( x >> 48 ) & 0xFF, - ( x >> 40 ) & 0xFF, - ( x >> 32 ) & 0xFF, - ( x >> 24 ) & 0xFF, - ( x >> 16 ) & 0xFF, - ( x >> 8 ) & 0xFF, - x & 0xFF }; + static_cast( ( x >> 56 ) & 0xFF ), + static_cast( ( x >> 48 ) & 0xFF ), + static_cast( ( x >> 40 ) & 0xFF ), + static_cast( ( x >> 32 ) & 0xFF ), + static_cast( ( x >> 24 ) & 0xFF ), + static_cast( ( x >> 16 ) & 0xFF ), + static_cast( ( x >> 8 ) & 0xFF ), + static_cast( ( x ) & 0xFF ) }; union { const uint8_t *p8; const uint64_t *p64; @@ -106,8 +106,8 @@ inline uint64_t be64toh( uint64_t x ) { inline uint16_t htobe16( uint16_t x ) { uint8_t xs[ 2 ] = { - ( x >> 8 ) & 0xFF, - x & 0xFF }; + static_cast( ( x >> 8 ) & 0xFF ), + static_cast( ( x ) & 0xFF ) }; union { const uint8_t *p8; const uint16_t *p16; diff --git a/src/crypto/crypto.cc b/src/crypto/crypto.cc index ddfde6b..a8c035a 100644 --- a/src/crypto/crypto.cc +++ b/src/crypto/crypto.cc @@ -65,6 +65,9 @@ AlignedBuffer::AlignedBuffer( size_t len, const char *data ) : m_len( len ), m_allocated( NULL ), m_data( NULL ) { #if defined(HAVE_POSIX_MEMALIGN) + if ( len == 0 ) { + len = 1; + } if ( ( 0 != posix_memalign( &m_allocated, 16, len ) ) || ( m_allocated == NULL ) ) { throw std::bad_alloc(); diff --git a/src/tests/e2e-test b/src/tests/e2e-test index a914b6d..1c73bdf 100755 --- a/src/tests/e2e-test +++ b/src/tests/e2e-test @@ -17,8 +17,6 @@ error() dump_logs() { - local dir - local testname dir=$1 shift testname=$(basename $dir .d) @@ -60,7 +58,6 @@ test_exitstatus() # Tmux check. tmux_check() { - local version version_major version_minor version=$(tmux -V) if [ $? != 0 ]; then error "tmux unavailable\n" diff --git a/src/tests/emulation-ascii-iso-8859.test b/src/tests/emulation-ascii-iso-8859.test index 9df910a..ed0c419 100755 --- a/src/tests/emulation-ascii-iso-8859.test +++ b/src/tests/emulation-ascii-iso-8859.test @@ -63,23 +63,22 @@ chr() utf8cp() { - local c=$1 - if [ $c -gt $((0x10ffff)) ]; then - fail "illegal Unicode code point %x\n" $c - elif [ $c -lt $((0x80)) ]; then - chr $c - elif [ $c -lt $((0x800)) ]; then - chr $(( (($c >> 6) & 0x1f) | 0xc0 )) - chr $(( ($c & 0x3f) | 0x80 )) - elif [ $c -lt $((0x10000)) ]; then - chr $(( (($c >> 12) & 0x0f) | 0xe0 )) - chr $(( (($c >> 6) & 0x3f) | 0x80 )) - chr $(( ($c & 0x3f) | 0x80 )) - elif [ $c -lt $((0x200000)) ]; then - chr $(( (($c >> 18) & 0x03) | 0xf0 )) - chr $(( (($c >> 12) & 0x3f) | 0x80 )) - chr $(( (($c >> 6) & 0x3f) | 0x80 )) - chr $(( ($c & 0x3f) | 0x80 )) + if [ $1 -gt $((0x10ffff)) ]; then + fail "illegal Unicode code point %x\n" $1 + elif [ $1 -lt $((0x80)) ]; then + chr $1 + elif [ $1 -lt $((0x800)) ]; then + chr $(( (($1 >> 6) & 0x1f) | 0xc0 )) + chr $(( ($1 & 0x3f) | 0x80 )) + elif [ $1 -lt $((0x10000)) ]; then + chr $(( (($1 >> 12) & 0x0f) | 0xe0 )) + chr $(( (($1 >> 6) & 0x3f) | 0x80 )) + chr $(( ($1 & 0x3f) | 0x80 )) + elif [ $1 -lt $((0x200000)) ]; then + chr $(( (($1 >> 18) & 0x03) | 0xf0 )) + chr $(( (($1 >> 12) & 0x3f) | 0x80 )) + chr $(( (($1 >> 6) & 0x3f) | 0x80 )) + chr $(( ($1 & 0x3f) | 0x80 )) fi } diff --git a/src/tests/emulation-wrap-across-frames.test b/src/tests/emulation-wrap-across-frames.test index a037b17..e3d4e74 100755 --- a/src/tests/emulation-wrap-across-frames.test +++ b/src/tests/emulation-wrap-across-frames.test @@ -68,23 +68,22 @@ chr() utf8cp() { - local c=$1 - if [ $c -gt $((0x10ffff)) ]; then - fail "illegal Unicode code point %x\n" $c - elif [ $c -lt $((0x80)) ]; then - chr $c - elif [ $c -lt $((0x800)) ]; then - chr $(( (($c >> 6) & 0x1f) | 0xc0 )) - chr $(( ($c & 0x3f) | 0x80 )) - elif [ $c -lt $((0x10000)) ]; then - chr $(( (($c >> 12) & 0x0f) | 0xe0 )) - chr $(( (($c >> 6) & 0x3f) | 0x80 )) - chr $(( ($c & 0x3f) | 0x80 )) - elif [ $c -lt $((0x200000)) ]; then - chr $(( (($c >> 18) & 0x03) | 0xf0 )) - chr $(( (($c >> 12) & 0x3f) | 0x80 )) - chr $(( (($c >> 6) & 0x3f) | 0x80 )) - chr $(( ($c & 0x3f) | 0x80 )) + if [ $1 -gt $((0x10ffff)) ]; then + fail "illegal Unicode code point %x\n" $1 + elif [ $1 -lt $((0x80)) ]; then + chr $1 + elif [ $1 -lt $((0x800)) ]; then + chr $(( (($1 >> 6) & 0x1f) | 0xc0 )) + chr $(( ($1 & 0x3f) | 0x80 )) + elif [ $1 -lt $((0x10000)) ]; then + chr $(( (($1 >> 12) & 0x0f) | 0xe0 )) + chr $(( (($1 >> 6) & 0x3f) | 0x80 )) + chr $(( ($1 & 0x3f) | 0x80 )) + elif [ $1 -lt $((0x200000)) ]; then + chr $(( (($1 >> 18) & 0x03) | 0xf0 )) + chr $(( (($1 >> 12) & 0x3f) | 0x80 )) + chr $(( (($1 >> 6) & 0x3f) | 0x80 )) + chr $(( ($1 & 0x3f) | 0x80 )) fi } diff --git a/src/tests/prediction-unicode.test b/src/tests/prediction-unicode.test index 82b8e22..8927331 100755 --- a/src/tests/prediction-unicode.test +++ b/src/tests/prediction-unicode.test @@ -79,23 +79,22 @@ chr() utf8cp() { - local c=$1 - if [ $c -gt $((0x10ffff)) ]; then - fail "illegal Unicode code point %x\n" $c - elif [ $c -lt $((0x80)) ]; then - chr $c - elif [ $c -lt $((0x800)) ]; then - chr $(( (($c >> 6) & 0x1f) | 0xc0 )) - chr $(( ($c & 0x3f) | 0x80 )) - elif [ $c -lt $((0x10000)) ]; then - chr $(( (($c >> 12) & 0x0f) | 0xe0 )) - chr $(( (($c >> 6) & 0x3f) | 0x80 )) - chr $(( ($c & 0x3f) | 0x80 )) - elif [ $c -lt $((0x200000)) ]; then - chr $(( (($c >> 18) & 0x03) | 0xf0 )) - chr $(( (($c >> 12) & 0x3f) | 0x80 )) - chr $(( (($c >> 6) & 0x3f) | 0x80 )) - chr $(( ($c & 0x3f) | 0x80 )) + if [ $1 -gt $((0x10ffff)) ]; then + fail "illegal Unicode code point %x\n" $1 + elif [ $1 -lt $((0x80)) ]; then + chr $1 + elif [ $1 -lt $((0x800)) ]; then + chr $(( (($1 >> 6) & 0x1f) | 0xc0 )) + chr $(( ($1 & 0x3f) | 0x80 )) + elif [ $1 -lt $((0x10000)) ]; then + chr $(( (($1 >> 12) & 0x0f) | 0xe0 )) + chr $(( (($1 >> 6) & 0x3f) | 0x80 )) + chr $(( ($1 & 0x3f) | 0x80 )) + elif [ $1 -lt $((0x200000)) ]; then + chr $(( (($1 >> 18) & 0x03) | 0xf0 )) + chr $(( (($1 >> 12) & 0x3f) | 0x80 )) + chr $(( (($1 >> 6) & 0x3f) | 0x80 )) + chr $(( ($1 & 0x3f) | 0x80 )) fi } diff --git a/src/tests/server-network-timeout.test b/src/tests/server-network-timeout.test index b2c7c4f..f3d4b9b 100755 --- a/src/tests/server-network-timeout.test +++ b/src/tests/server-network-timeout.test @@ -48,7 +48,7 @@ client() case $retval in 0|1) fail "mosh-client had a normal exit\n";; # test condition failed - 137) + 9|137|265) # Aha, signal 9. Wait. sleep $(( $TIMEOUT + 12 )) exit 0