From fe723808887245458f9cf494193138e63f31c000 Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Fri, 24 Jul 2020 19:36:55 -0400 Subject: [PATCH] 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 --- src/sock.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/sock.c b/src/sock.c index e5156b5..a60c406 100644 --- a/src/sock.c +++ b/src/sock.c @@ -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; }