summaryrefslogtreecommitdiffstats
path: root/ssl/ssl_lib.c
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2016-02-12 12:03:58 +0000
committerMatt Caswell <matt@openssl.org>2016-03-07 21:39:27 +0000
commit49580f25b3e6239a277c9fc2708c0354f419ec17 (patch)
tree999a9deacba23fb70b41ab170aca8f2a21650e4e /ssl/ssl_lib.c
parentdad78fb13d790cd06afd6e88067c038d22d7780f (diff)
Add an SSL_has_pending() function
This is similar to SSL_pending() but just returns a 1 if there is data pending in the internal OpenSSL buffers or 0 otherwise (as opposed to SSL_pending() which returns the number of bytes available). Unlike SSL_pending() this will work even if "read_ahead" is set (which is the case if you are using read pipelining, or if you are doing DTLS). A 1 return value means that we have unprocessed data. It does *not* necessarily indicate that there will be application data returned from a call to SSL_read(). The unprocessed data may not be application data or there could be errors when we attempt to parse the records. Reviewed-by: Tim Hudson <tjh@openssl.org>
Diffstat (limited to 'ssl/ssl_lib.c')
-rw-r--r--ssl/ssl_lib.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c
index 4df8339979..89d228600c 100644
--- a/ssl/ssl_lib.c
+++ b/ssl/ssl_lib.c
@@ -1310,6 +1310,22 @@ int SSL_pending(const SSL *s)
return (s->method->ssl_pending(s));
}
+int SSL_has_pending(const SSL *s)
+{
+ /*
+ * Similar to SSL_pending() but returns a 1 to indicate that we have
+ * unprocessed data available or 0 otherwise (as opposed to the number of
+ * bytes available). Unlike SSL_pending() this will take into account
+ * read_ahead data. A 1 return simply indicates that we have unprocessed
+ * data. That data may not result in any application data, or we may fail
+ * to parse the records for some reason.
+ */
+ if (SSL_pending(s))
+ return 1;
+
+ return RECORD_LAYER_read_pending(&s->rlayer);
+}
+
X509 *SSL_get_peer_certificate(const SSL *s)
{
X509 *r;