From: Nikos Mavrogiannopoulos Date: Sun, 29 Jul 2001 23:21:31 +0000 (+0000) Subject: fixes in EOF handling in handshake. X-Git-Tag: gnutls_0_1_9~3 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=b861a7b79ecd5f9b8622b7cfc2842404089c2285;p=thirdparty%2Fgnutls.git fixes in EOF handling in handshake. --- diff --git a/lib/gnutls_handshake.c b/lib/gnutls_handshake.c index 7d86a592ba..476e419e0d 100644 --- a/lib/gnutls_handshake.c +++ b/lib/gnutls_handshake.c @@ -633,7 +633,7 @@ int _gnutls_recv_handshake(SOCKET cd, GNUTLS_STATE state, uint8 ** data, if (ret <= 0) { gnutls_assert(); gnutls_free(dataptr); - return ret; + return (ret < 0)?ret:GNUTLS_E_UNEXPECTED_PACKET_LENGTH; } if (ret != SSL2_HEADERS) { gnutls_assert(); @@ -652,7 +652,7 @@ int _gnutls_recv_handshake(SOCKET cd, GNUTLS_STATE state, uint8 ** data, if (ret <= 0) { gnutls_assert(); gnutls_free(dataptr); - return ret; + return (ret<0)?ret:GNUTLS_E_UNEXPECTED_PACKET_LENGTH; } if (ret != HANDSHAKE_HEADERS_SIZE - SSL2_HEADERS) { gnutls_assert(); @@ -1429,7 +1429,7 @@ static int _gnutls_recv_handshake_final(SOCKET cd, GNUTLS_STATE state, if (ret <= 0) { ERR("recv ChangeCipherSpec", ret); gnutls_assert(); - return ret; + return (ret<0)?ret:GNUTLS_E_UNEXPECTED_PACKET_LENGTH; } /* Initialize the connection state (start encryption) - in case of server */ diff --git a/lib/gnutls_record.c b/lib/gnutls_record.c index 8ad7b9db60..ce203399ca 100644 --- a/lib/gnutls_record.c +++ b/lib/gnutls_record.c @@ -808,9 +808,20 @@ ssize_t gnutls_recv_int(SOCKET cd, GNUTLS_STATE state, ContentType type, Handsha return GNUTLS_E_UNEXPECTED_PACKET; case GNUTLS_APPLICATION_DATA: +#if 0 /* even if data is unexpected put it into the buffer */ gnutls_insertDataBuffer(recv_type, state, (void *) tmpdata, tmplen); /* no peeked data to clear since this packet was unexpected */ +#endif + /* We no longer assume this as normal, since + * in this case we don't leave data into kernel + * buffer, thus select() will not return. + * Return an error for now, and we'll handle + * it if there is a need for it. + */ + gnutls_assert(); + gnutls_free(tmpdata); + return GNUTLS_E_UNEXPECTED_PACKET; break; case GNUTLS_HANDSHAKE: