diff options
author | Ondrej Zajicek <santiago@crfreenet.org> | 2015-07-19 11:39:24 +0200 |
---|---|---|
committer | Ondrej Zajicek <santiago@crfreenet.org> | 2015-07-19 11:39:24 +0200 |
commit | ffa398b8d8bac4cf6368fe700466cad4ff12fee8 (patch) | |
tree | 2ebb226b129e9d7fe50bc57c928694ffc9e19a59 /proto/bfd/packets.c | |
parent | a8ad8fd6491d04620fe4fdebc50f0da2927f9b21 (diff) |
BFD: Fixes crash after socket error
Thanks to Thomas King for the bugreport.
Diffstat (limited to 'proto/bfd/packets.c')
-rw-r--r-- | proto/bfd/packets.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/proto/bfd/packets.c b/proto/bfd/packets.c index b5fd6782..cb40bcda 100644 --- a/proto/bfd/packets.c +++ b/proto/bfd/packets.c @@ -63,9 +63,13 @@ void bfd_send_ctl(struct bfd_proto *p, struct bfd_session *s, int final) { sock *sk = s->ifa->sk; - struct bfd_ctl_packet *pkt = (struct bfd_ctl_packet *) sk->tbuf; + struct bfd_ctl_packet *pkt; char fb[8]; + if (!sk) + return; + + pkt = (struct bfd_ctl_packet *) sk->tbuf; pkt->vdiag = bfd_pack_vdiag(1, s->loc_diag); pkt->flags = bfd_pack_flags(s->loc_state, 0); pkt->detect_mult = s->detect_mult; @@ -139,7 +143,7 @@ bfd_rx_hook(sock *sk, int len) u8 ps = bfd_pkt_get_state(pkt); if (ps > BFD_STATE_DOWN) DROP("invalid init state", ps); - + s = bfd_find_session_by_addr(p, sk->faddr); /* FIXME: better session matching and message */ |