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:
parent
2c585ca4fe
commit
fe72380888
1 changed files with 14 additions and 0 deletions
14
src/sock.c
14
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue