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();
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();
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 */
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: