Skip to content

Commit bbe156b

Browse files
committed
PR feedback
1 parent 1d8b2a4 commit bbe156b

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

crypto/bio/dgram.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ static int dgram_read(BIO *bp, char *out, const int out_len) {
161161
BIO_ADDR_sockaddr_noconst(&peer), &len);
162162

163163
if (result < INT_MIN || result > INT_MAX) {
164-
abort();
164+
OPENSSL_PUT_ERROR(BIO, BIO_R_SYS_LIB);
165+
return -1;
165166
}
166167
const int ret = result;
167168

@@ -194,6 +195,7 @@ static int dgram_free(BIO *bp) {
194195
}
195196
}
196197
bp->init = 0;
198+
bp->num = -1;
197199
bp->flags = 0;
198200
OPENSSL_free(bp->ptr);
199201
bp->ptr = NULL;

crypto/bio/internal.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ int bio_socket_nbio(int sock, int on);
9898
// bio_clear_socket_error clears the last socket error on |sock|.
9999
void bio_clear_socket_error(int sock);
100100

101-
// bio_sock_error returns the last socket error on |sock|.
101+
// bio_sock_error_get_and_clear clears and returns the last socket error on |sock|.
102102
int bio_sock_error_get_and_clear(int sock);
103103

104104
// bio_socket_should_retry returns non-zero if |return_value| indicates an error

include/openssl/bio.h

+6-4
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ typedef union bio_addr_st {
723723
#endif
724724
} BIO_ADDR;
725725

726-
#define BIO_CTRL_DGRAM_CONNECT 31// BIO dgram special
726+
#define BIO_CTRL_DGRAM_CONNECT 31 // BIO dgram special
727727
#define BIO_CTRL_DGRAM_SET_CONNECTED 32 /* allow for an externally connected
728728
* socket to be passed in */
729729

@@ -765,12 +765,14 @@ OPENSSL_EXPORT int BIO_ctrl_dgram_connect(BIO *bp, const BIO_ADDR *peer);
765765
OPENSSL_EXPORT int BIO_ctrl_set_connected(BIO* bp, const BIO_ADDR *peer);
766766

767767
// BIO_dgram_recv_timedout returns 1 if the most recent datagram receive
768-
// operation on |bp| timed out, and a non-positive value otherwise.
768+
// operation on |bp| timed out, and a non-positive value otherwise. Any error
769+
// for this socket gets reset by this call.
769770
OPENSSL_EXPORT int BIO_dgram_recv_timedout(BIO* bp);
770771

771772
// BIO_dgram_send_timedout returns 1 if the most recent datagram send
772-
// operation on |bp| timed out, and a non-positive value otherwise.
773-
OPENSSL_EXPORT int BIO_dgram_send_timedout(BIO* bp);
773+
// operation on |bp| timed out, and a non-positive value otherwise. Any error
774+
// for this socket gets reset by this call.
775+
OPENSSL_EXPORT int BIO_dgram_send_timedout(BIO *bp);
774776

775777
// BIO_dgram_get_peer stores the address of the peer the datagram BIO is
776778
// connected to in |peer|. It returns 1 on success and a non-positive value on error.

0 commit comments

Comments
 (0)