Minor updates
authorHugo Landau <hlandau@openssl.org>
Fri, 18 Aug 2023 11:06:10 +0000 (12:06 +0100)
committerHugo Landau <hlandau@openssl.org>
Fri, 1 Sep 2023 09:45:36 +0000 (10:45 +0100)
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21715)

crypto/bio/bss_conn.c
doc/man3/BIO_s_connect.pod
include/openssl/bio.h.in
ssl/quic/quic_impl.c
util/other.syms

index 8d29f94bd120fb50e347c9deaf9fa0d3a61c18a1..f09160b3c0c98ae0801d1ab8ef6501b273c831c7 100644 (file)
@@ -347,8 +347,7 @@ static int conn_free(BIO *a)
         return 0;
     data = (BIO_CONNECT *)a->ptr;
 
-    if (data->dgram_bio != NULL)
-        BIO_free(data->dgram_bio);
+    BIO_free(data->dgram_bio);
 
     if (a->shutdown) {
         conn_close_socket(a);
@@ -372,8 +371,12 @@ static int conn_read(BIO *b, char *out, int outl)
             return ret;
     }
 
-    if (data->dgram_bio != NULL)
-        return BIO_read(data->dgram_bio, out, outl);
+    if (data->dgram_bio != NULL) {
+        BIO_clear_retry_flags(b);
+        ret = BIO_read(data->dgram_bio, out, outl);
+        BIO_set_flags(b, BIO_get_retry_flags(data->dgram_bio));
+        return ret;
+    }
 
     if (out != NULL) {
         clear_socket_error();
@@ -406,8 +409,12 @@ static int conn_write(BIO *b, const char *in, int inl)
             return ret;
     }
 
-    if (data->dgram_bio != NULL)
-        return BIO_write(data->dgram_bio, in, inl);
+    if (data->dgram_bio != NULL) {
+        BIO_clear_retry_flags(b);
+        ret = BIO_write(data->dgram_bio, in, inl);
+        BIO_set_flags(b, BIO_get_retry_flags(data->dgram_bio));
+        return ret;
+    }
 
     clear_socket_error();
 # ifndef OPENSSL_NO_KTLS
index 0c1106c5234e9d08c5b3d0030c975c85c6121adc..35d67787ffe05b8992fb9f7fc92ccf3c6ce4df7c 100644 (file)
@@ -7,7 +7,7 @@ BIO_set_conn_hostname, BIO_set_conn_port,
 BIO_set_conn_address, BIO_set_conn_ip_family,
 BIO_get_conn_hostname, BIO_get_conn_port,
 BIO_get_conn_address, BIO_get_conn_ip_family,
-BIO_set_nbio, BIO_set_sock_type, BIO_get_sock_type, BIO_get_dgram_bio,
+BIO_set_nbio, BIO_set_sock_type, BIO_get_sock_type, BIO_get0_dgram_bio,
 BIO_do_connect - connect BIO
 
 =head1 SYNOPSIS
@@ -31,7 +31,7 @@ BIO_do_connect - connect BIO
 
  int BIO_set_sock_type(BIO *b, int sock_type);
  int BIO_get_sock_type(BIO *b);
- int BIO_get_dgram_bio(BIO *B, BIO **dgram_bio);
+ int BIO_get0_dgram_bio(BIO *B, BIO **dgram_bio);
 
  long BIO_do_connect(BIO *b);
 
@@ -112,8 +112,10 @@ default) and B<SOCK_DGRAM>. If B<SOCK_DGRAM> is configured, the connection
 created is a UDP datagram socket handled via L<BIO_s_datagram(3)>.
 I/O calls such as L<BIO_read(3)> and L<BIO_write(3)> are forwarded transparently
 to an internal L<BIO_s_datagram(3)> instance. The created L<BIO_s_datagram(3)>
-instance can be retrieved using BIO_get_dgram_bio() if desired, which writes
-a pointer to the L<BIO_s_datagram(3)> instance to I<*dgram_bio>.
+instance can be retrieved using BIO_get0_dgram_bio() if desired, which writes
+a pointer to the L<BIO_s_datagram(3)> instance to I<*dgram_bio>. The lifetime
+of the internal L<BIO_s_datagram(3)> is managed by BIO_s_connect() and does not
+need to be freed by the caller.
 
 BIO_get_sock_type() retrieves the value set using BIO_set_sock_type().
 
@@ -181,7 +183,7 @@ BIO_set_sock_type() returns 1 on success or 0 on failure.
 
 BIO_get_sock_type() returns a socket type or 0 if the call is not supported.
 
-BIO_get_dgram_bio() returns 1 on success or 0 on failure.
+BIO_get0_dgram_bio() returns 1 on success or 0 on failure.
 
 =head1 EXAMPLES
 
index e6af3470a5a485a249e3163ff0eaf66599042754..aa05d7d9cf41bd09074d0abf6da69a58f9b1f63e 100644 (file)
@@ -495,7 +495,7 @@ typedef struct bio_poll_descriptor_st {
 #  define BIO_set_conn_mode(b,n)        BIO_ctrl(b,BIO_C_SET_CONNECT_MODE,(n),NULL)
 #  define BIO_set_sock_type(b,t)        BIO_ctrl(b,BIO_C_SET_SOCK_TYPE,(t),NULL)
 #  define BIO_get_sock_type(b)          BIO_ctrl(b,BIO_C_GET_SOCK_TYPE,0,NULL)
-#  define BIO_get_dgram_bio(b, p)       BIO_ctrl(b,BIO_C_GET_DGRAM_BIO,0,(void *)(BIO **)(p))
+#  define BIO_get0_dgram_bio(b, p)      BIO_ctrl(b,BIO_C_GET_DGRAM_BIO,0,(void *)(BIO **)(p))
 
 /* BIO_s_accept() */
 #  define BIO_set_accept_name(b,name)   BIO_ctrl(b,BIO_C_SET_ACCEPT,0, \
index 839168040b9144ccbf5b155fda59ef1b6cf19211..11c8afce8acb143d1f6c1ab6d230651b8733d47a 100644 (file)
@@ -1581,7 +1581,7 @@ static int quic_do_handshake(QCTX *ctx)
          * We do this as late as possible because some BIOs (e.g. BIO_s_connect)
          * may not be able to provide us with a peer address until they have
          * finished their own processing. They may not be able to perform this
-         * processing until an application has figured configuring that BIO
+         * processing until an application has finished configuring that BIO
          * (e.g. with setter calls), which might happen after SSL_set_bio is
          * called.
          */
index cd1f73468dbd0d0d55ee398d28d1b154fbc00d28..4bac4afeaadb0354a8658c36325bde8a1b0b1523 100644 (file)
@@ -169,7 +169,7 @@ BIO_dgram_set_peer                      define
 BIO_dgram_recv_timedout                 define
 BIO_dgram_send_timedout                 define
 BIO_dgram_detect_peer_addr              define
-BIO_get_dgram_bio                       define
+BIO_get0_dgram_bio                      define
 BIO_get_sock_type                       define
 BIO_set_sock_type                       define
 BIO_do_accept                           define