summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@crystal.(none)>2007-10-06 21:21:22 +0300
committerNikos Mavrogiannopoulos <nmav@crystal.(none)>2007-10-06 21:21:22 +0300
commit96183cb39b38e7f5cf0b58929ef5868ed5639096 (patch)
treed2941d33c9efafdd9d38e07850bb1cace0ace51e
parent3fbfc5c212c2ba6322edfd65cb4cc4fc87f410d6 (diff)
downloadgnutls-96183cb39b38e7f5cf0b58929ef5868ed5639096.tar.gz
error_to_alert() now always return an alert number. This is to avoid sending illegal values
when the return value is not checked (commonplace).
-rw-r--r--lib/gnutls_alert.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/gnutls_alert.c b/lib/gnutls_alert.c
index 92431bc799..449019b8d1 100644
--- a/lib/gnutls_alert.c
+++ b/lib/gnutls_alert.c
@@ -148,15 +148,14 @@ gnutls_alert_send (gnutls_session_t session, gnutls_alert_level_t level,
* alert should be sent to the peer indicating that no renegotiation will
* be performed.
*
- * If the return value is GNUTLS_E_INVALID_REQUEST, then there was no
- * mapping to an alert.
+ * If there is no mapping to a valid alert the alert to indicate internal error
+ * is returned.
*
**/
int
gnutls_error_to_alert (int err, int *level)
{
- int ret = GNUTLS_E_INVALID_REQUEST;
- int _level = -1;
+ int ret, _level = -1;
switch (err)
{ /* send appropriate alert */
@@ -241,6 +240,10 @@ gnutls_error_to_alert (int err, int *level)
ret = GNUTLS_A_INSUFFICIENT_SECURITY;
_level = GNUTLS_AL_FATAL;
break;
+ default:
+ ret = GNUTLS_A_INTERNAL_ERROR;
+ _level = GNUTLS_AL_FATAL;
+ break;
}
if (level != NULL)