diff options
author | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2016-10-14 10:22:07 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2016-10-14 11:39:02 +0200 |
commit | 2e03a21f0d038cff25e7920ebc3bb8e6a89ea2ce (patch) | |
tree | 15520bdaaea5b6e2bd2d8295be14d85dc4b2fc7f /lib/handshake.c | |
parent | cc13856fd3bff6cc1918851ae2c3618a3453fbe5 (diff) | |
download | gnutls-tmp-multi-alert.tar.gz |
handshake: set a maximum number of warning messages that can be received per handshaketmp-multi-alert
That is to avoid DoS due to the assymetry of cost of sending an alert vs the cost
of processing.
Diffstat (limited to 'lib/handshake.c')
-rw-r--r-- | lib/handshake.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/handshake.c b/lib/handshake.c index 8224077083..f81dd74beb 100644 --- a/lib/handshake.c +++ b/lib/handshake.c @@ -2675,12 +2675,17 @@ gnutls_handshake_set_timeout(gnutls_session_t session, unsigned int ms) return ret; \ if (ret == GNUTLS_E_GOT_APPLICATION_DATA && session->internals.initial_negotiation_completed != 0) \ return ret; \ - if (ret == GNUTLS_E_LARGE_PACKET && session->internals.handshake_large_loops < 16) { \ - session->internals.handshake_large_loops++; \ - return ret; \ + if (session->internals.handshake_suspicious_loops < 16) { \ + if (ret == GNUTLS_E_LARGE_PACKET) { \ + session->internals.handshake_suspicious_loops++; \ + return ret; \ + } \ + /* a warning alert might interrupt handshake */ \ + if (allow_alert != 0 && ret==GNUTLS_E_WARNING_ALERT_RECEIVED) { \ + session->internals.handshake_suspicious_loops++; \ + return ret; \ + } \ } \ - /* a warning alert might interrupt handshake */ \ - if (allow_alert != 0 && ret==GNUTLS_E_WARNING_ALERT_RECEIVED) return ret; \ gnutls_assert(); \ ERR( str, ret); \ /* do not allow non-fatal errors at this point */ \ |