diff options
author | Colin Watson <cjwatson@debian.org> | 2017-01-01 15:21:10 +0000 |
---|---|---|
committer | Colin Watson <cjwatson@debian.org> | 2017-01-01 15:29:22 +0000 |
commit | ada7edd8b4ec246a0c1c283c5e5956f09d503fbd (patch) | |
tree | 53f2abb82964aa03f39e9d66600ae137327b2da3 /regress | |
parent | 624433c4fff092e3aaaff6aa8954eb93e0387c44 (diff) |
Make integrity tests more robust against timeouts
If the first test in a series for a given MAC happens to modify the low
bytes of a packet length, then ssh will time out and this will be
interpreted as a test failure. Handle this failure mode.
Bug: https://bugzilla.mindrot.org/show_bug.cgi?id=2658
Patch-Name: regress-integrity-robust.patch
Last-Update: 2017-01-01
Diffstat (limited to 'regress')
-rw-r--r-- | regress/integrity.sh | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/regress/integrity.sh b/regress/integrity.sh index 39d310deb..fd7d58bcb 100644 --- a/regress/integrity.sh +++ b/regress/integrity.sh | |||
@@ -5,8 +5,6 @@ tid="integrity" | |||
5 | cp $OBJ/sshd_proxy $OBJ/sshd_proxy_bak | 5 | cp $OBJ/sshd_proxy $OBJ/sshd_proxy_bak |
6 | 6 | ||
7 | # start at byte 2900 (i.e. after kex) and corrupt at different offsets | 7 | # start at byte 2900 (i.e. after kex) and corrupt at different offsets |
8 | # XXX the test hangs if we modify the low bytes of the packet length | ||
9 | # XXX and ssh tries to read... | ||
10 | tries=10 | 8 | tries=10 |
11 | startoffset=2900 | 9 | startoffset=2900 |
12 | macs=`${SSH} -Q mac` | 10 | macs=`${SSH} -Q mac` |
@@ -27,6 +25,7 @@ for m in $macs; do | |||
27 | elen=0 | 25 | elen=0 |
28 | epad=0 | 26 | epad=0 |
29 | emac=0 | 27 | emac=0 |
28 | etmo=0 | ||
30 | ecnt=0 | 29 | ecnt=0 |
31 | skip=0 | 30 | skip=0 |
32 | for off in `jot $tries $startoffset`; do | 31 | for off in `jot $tries $startoffset`; do |
@@ -61,14 +60,16 @@ for m in $macs; do | |||
61 | Corrupted?MAC* | *message?authentication?code?incorrect*) | 60 | Corrupted?MAC* | *message?authentication?code?incorrect*) |
62 | emac=`expr $emac + 1`; skip=0;; | 61 | emac=`expr $emac + 1`; skip=0;; |
63 | padding*) epad=`expr $epad + 1`; skip=0;; | 62 | padding*) epad=`expr $epad + 1`; skip=0;; |
63 | *Timeout,?server*) | ||
64 | etmo=`expr $etmo + 1`; skip=0;; | ||
64 | *) fail "unexpected error mac $m at $off: $out";; | 65 | *) fail "unexpected error mac $m at $off: $out";; |
65 | esac | 66 | esac |
66 | done | 67 | done |
67 | verbose "test $tid: $ecnt errors: mac $emac padding $epad length $elen" | 68 | verbose "test $tid: $ecnt errors: mac $emac padding $epad length $elen timeout $etmo" |
68 | if [ $emac -eq 0 ]; then | 69 | if [ $emac -eq 0 ]; then |
69 | fail "$m: no mac errors" | 70 | fail "$m: no mac errors" |
70 | fi | 71 | fi |
71 | expect=`expr $ecnt - $epad - $elen` | 72 | expect=`expr $ecnt - $epad - $elen - $etmo` |
72 | if [ $emac -ne $expect ]; then | 73 | if [ $emac -ne $expect ]; then |
73 | fail "$m: expected $expect mac errors, got $emac" | 74 | fail "$m: expected $expect mac errors, got $emac" |
74 | fi | 75 | fi |