}
# else
socklen_t sz = sizeof(struct timeval);
+
if ((ret = getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO,
ptr, &sz)) < 0) {
ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
"calling getsockopt()");
+ } else if (!ossl_assert((size_t)sz == sizeof(struct timeval))) {
+ ERR_raise_data(ERR_LIB_BIO, ERR_R_INTERNAL_ERROR,
+ "Unexpected getsockopt(SO_RCVTIMEO) return size");
+ ret = -1;
} else {
- OPENSSL_assert((size_t)sz <= sizeof(struct timeval));
ret = (int)sz;
}
# endif
ptr, &sz)) < 0) {
ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
"calling getsockopt()");
+ } else if (!ossl_assert((size_t)sz == sizeof(struct timeval))) {
+ ERR_raise_data(ERR_LIB_BIO, ERR_R_INTERNAL_ERROR,
+ "Unexpected getsockopt(SO_SNDTIMEO) return size");
+ ret = -1;
} else {
- OPENSSL_assert((size_t)sz <= sizeof(struct timeval));
ret = (int)sz;
}
# endif
if (msg.msg_flags & MSG_NOTIFICATION) {
union sctp_notification snp;
- memcpy(&snp, out, sizeof(snp));
+ if (n < (int)sizeof(snp.sn_header))
+ return -1;
+ memset(&snp, 0, sizeof(snp));
+ memcpy(&snp, out, (size_t)n < sizeof(snp) ? (size_t)n : sizeof(snp));
if (snp.sn_header.sn_type == SCTP_SENDER_DRY_EVENT) {
# ifdef SCTP_EVENT
struct sctp_event event;
data->handle_notifications(b, data->notification_context,
(void *)out);
- memset(&snp, 0, sizeof(snp));
memset(out, 0, outl);
} else {
ret += n;
*/
optlen = (socklen_t) sizeof(int);
ret = getsockopt(b->num, SOL_SOCKET, SO_RCVBUF, &optval, &optlen);
- if (ret >= 0)
- OPENSSL_assert(optval >= 18445);
+ if (ret >= 0 && !ossl_assert(optval >= 18445))
+ return -1;
/*
* Test if SCTP doesn't partially deliver below max record size
ret =
getsockopt(b->num, IPPROTO_SCTP, SCTP_PARTIAL_DELIVERY_POINT,
&optval, &optlen);
- if (ret >= 0)
- OPENSSL_assert(optval >= 18445);
+ if (ret >= 0 && !ossl_assert(optval >= 18445))
+ return -1;
/*
* Partially delivered notification??? Probably a bug....
*/
- OPENSSL_assert(!(msg.msg_flags & MSG_NOTIFICATION));
+ if (!ossl_assert((msg.msg_flags & MSG_NOTIFICATION) == 0))
+ return -1;
/*
* Everything seems ok till now, so it's most likely a message