Add validation to patty_ax25_sock_send()

Changes:

    * Make patty_ax25_sock_send() set ENETDOWN when no network interface
      is associated with a sock

    * Make patty_ax25_sock_send() set EBADF when no remote address is
      associated with a sock
This commit is contained in:
XANTRONIX Development 2020-07-24 19:36:55 -04:00 committed by XANTRONIX Industrial
parent 2c585ca4fe
commit fe72380888

View file

@ -363,6 +363,18 @@ ssize_t patty_ax25_sock_send(patty_ax25_sock *sock,
uint8_t *buf = PATTY_AX25_FRAME_CONTROL_U(control)?
sock->tx_buf: tx_slot(sock, sock->seq_send);
if (sock->iface == NULL) {
errno = ENETDOWN;
goto error_noif;
}
if (sock->remote.callsign[0] == '\0') {
errno = EBADF;
goto error_nopeer;
}
if (toobig(sock, infolen)) {
goto error_toobig;
}
@ -393,6 +405,8 @@ ssize_t patty_ax25_sock_send(patty_ax25_sock *sock,
error_encode_address:
error_toobig:
error_nopeer:
error_noif:
return -1;
}