diff options
author | Paul Querna | 2005-09-25 18:27:08 +0000 |
---|---|---|
committer | Paul Querna | 2005-09-25 18:27:08 +0000 |
commit | 8e33f2d4c149fe8b6d2f1f3bdb06c52da53952f1 (patch) | |
tree | 9fb01379fa6c1f6ca9c39d431a2631938300b1ed /src | |
parent | 740a39e9f7bda141730a067c8513a1ed6a6c836b (diff) |
Put a limit on the number of times we try to handshake.
Diffstat (limited to 'src')
-rw-r--r-- | src/gnutls_io.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/gnutls_io.c b/src/gnutls_io.c index 925517b..14e7cf6 100644 --- a/src/gnutls_io.c +++ b/src/gnutls_io.c | |||
@@ -353,10 +353,13 @@ static apr_status_t gnutls_io_input_getline(mgs_handle_t * ctxt, | |||
353 | return APR_SUCCESS; | 353 | return APR_SUCCESS; |
354 | } | 354 | } |
355 | 355 | ||
356 | #define HANDSHAKE_MAX_TRIES 100 | ||
356 | static int gnutls_do_handshake(mgs_handle_t * ctxt) | 357 | static int gnutls_do_handshake(mgs_handle_t * ctxt) |
357 | { | 358 | { |
358 | int ret; | 359 | int ret; |
359 | int errcode; | 360 | int errcode; |
361 | int maxtries = HANDSHAKE_MAX_TRIES; | ||
362 | |||
360 | if (ctxt->status != 0) { | 363 | if (ctxt->status != 0) { |
361 | return -1; | 364 | return -1; |
362 | } | 365 | } |
@@ -364,8 +367,24 @@ static int gnutls_do_handshake(mgs_handle_t * ctxt) | |||
364 | tryagain: | 367 | tryagain: |
365 | do { | 368 | do { |
366 | ret = gnutls_handshake(ctxt->session); | 369 | ret = gnutls_handshake(ctxt->session); |
367 | } while (ret == GNUTLS_E_AGAIN); | 370 | maxtries--; |
368 | 371 | } while (ret == GNUTLS_E_AGAIN && maxtries > 0); | |
372 | |||
373 | if (maxtries < 1) { | ||
374 | ctxt->status = -1; | ||
375 | #if USING_2_1_RECENT | ||
376 | ap_log_cerror(APLOG_MARK, APLOG_ERR, 0, ctxt->c, | ||
377 | "GnuTLS: Handshake Failed. Hit Maximum Attempts"); | ||
378 | #else | ||
379 | ap_log_error(APLOG_MARK, APLOG_ERR, 0, ctxt->c->base_server, | ||
380 | "GnuTLS: Handshake Failed. Hit Maximum Attempts"); | ||
381 | #endif | ||
382 | gnutls_alert_send(ctxt->session, GNUTLS_AL_FATAL, | ||
383 | gnutls_error_to_alert(ret, NULL)); | ||
384 | gnutls_deinit(ctxt->session); | ||
385 | return -1; | ||
386 | } | ||
387 | |||
369 | if (ret < 0) { | 388 | if (ret < 0) { |
370 | if (ret == GNUTLS_E_WARNING_ALERT_RECEIVED | 389 | if (ret == GNUTLS_E_WARNING_ALERT_RECEIVED |
371 | || ret == GNUTLS_E_FATAL_ALERT_RECEIVED) { | 390 | || ret == GNUTLS_E_FATAL_ALERT_RECEIVED) { |