X-Git-Url: https://www.bearssl.org/gitweb//home/git/?p=BearSSL;a=blobdiff_plain;f=src%2Fssl%2Fssl_engine.c;h=9c7739e87aeb1d005757857f63b713f91dba1a11;hp=f4ffe1854724da42a2db226fd59ce2cb2de0ef82;hb=946f5bad7683aa79a9f4fcab760206e2aad8c555;hpb=252dba914912e694d0e69754f0167060fc4d2ba6 diff --git a/src/ssl/ssl_engine.c b/src/ssl/ssl_engine.c index f4ffe18..9c7739e 100644 --- a/src/ssl/ssl_engine.c +++ b/src/ssl/ssl_engine.c @@ -1232,6 +1232,21 @@ void br_ssl_engine_close(br_ssl_engine_context *cc) { if (!br_ssl_engine_closed(cc)) { + /* + * If we are not already closed, then we need to + * initiate the closure. Once closing, any incoming + * application data is discarded; we should also discard + * application data which is alreayd there but has not + * been acknowledged by the application yet (this mimics + * usual semantics on BSD sockets: you cannot read() + * once you called close(), even if there was some + * unread data already buffered). + */ + size_t len; + + if (br_ssl_engine_recvapp_buf(cc, &len) != NULL && len != 0) { + br_ssl_engine_recvapp_ack(cc, len); + } jump_handshake(cc, 1); } }