diff --git a/arp.c b/arp.c index 0aae069..2b4c664 100644 --- a/arp.c +++ b/arp.c @@ -55,7 +55,7 @@ void sendarp(int ifr_idx, const unsigned char* mac, in_addr_t ip) memset(&sll, 0, sizeof(sll)); sll.sll_family = AF_PACKET; - memcpy(sll.sll_addr, mac, sizeof(sll.sll_addr) - 1); + memcpy(sll.sll_addr, mac, ETH_ALEN); sll.sll_halen = ETH_ALEN; sll.sll_ifindex = ifr_idx; diff --git a/bgp.c b/bgp.c index 2791ca3..181de9a 100644 --- a/bgp.c +++ b/bgp.c @@ -1028,7 +1028,7 @@ static int bgp_write(struct bgp_peer *peer) int len = htons(peer->outbuf->packet.header.len); int r; - while ((r = write(peer->sock, &peer->outbuf->packet + peer->outbuf->done, + while ((r = write(peer->sock, (char*)&peer->outbuf->packet + peer->outbuf->done, len - peer->outbuf->done)) == -1) { if (errno == EINTR) diff --git a/l2tpns.c b/l2tpns.c index 2eb39bf..8bbe46c 100644 --- a/l2tpns.c +++ b/l2tpns.c @@ -2705,6 +2705,8 @@ void processudp(uint8_t *buf, int len, struct sockaddr_in *addr, uint16_t indexu { LOG(1, s, t, "Invalid length in AVP\n"); STAT(tunnel_rx_errors); + free(sendchalresponse); + free(recvchalresponse); return; } p += n; // next @@ -3250,6 +3252,8 @@ void processudp(uint8_t *buf, int len, struct sockaddr_in *addr, uint16_t indexu controladd(c, asession, t); // send the message } + free(sendchalresponse); + free(recvchalresponse); return; case 11: // ICRP LOG(3, s, t, "Received ICRP\n"); @@ -3304,8 +3308,8 @@ void processudp(uint8_t *buf, int len, struct sockaddr_in *addr, uint16_t indexu LOG(1, s, t, "Unknown message type %u\n", message); break; } - if (sendchalresponse) free(sendchalresponse); - if (recvchalresponse) free(recvchalresponse); + free(sendchalresponse); + free(recvchalresponse); cluster_send_tunnel(t); } else diff --git a/pppoe.c b/pppoe.c index c6bc12d..28d0661 100644 --- a/pppoe.c +++ b/pppoe.c @@ -343,7 +343,7 @@ static void pppoe_disc_send(const uint8_t *pack) void pppoe_sess_send(const uint8_t *pack, uint16_t l, tunnelidt t) { - struct pppoe_hdr *hdr = (struct pppoe_hdr *)(pack + ETH_HLEN); + struct pppoe_hdr *hdr; int n; uint16_t sizeppp; sessionidt s; @@ -354,6 +354,13 @@ void pppoe_sess_send(const uint8_t *pack, uint16_t l, tunnelidt t) return; } + if (l < (ETH_HLEN + sizeof(*hdr) + 3)) + { + LOG(3, 0, t, "ERROR pppoe_sess_send: packet too small for pppoe sent (size=%d)\n", l); + return; + } + + hdr = (struct pppoe_hdr *)(pack + ETH_HLEN); s = ntohs(hdr->sid); if (session[s].tunnel != t) { @@ -361,12 +368,6 @@ void pppoe_sess_send(const uint8_t *pack, uint16_t l, tunnelidt t) return; } - if (l < (ETH_HLEN + sizeof(*hdr) + 3)) - { - LOG(0, s, t, "ERROR pppoe_sess_send: packet too small for pppoe sent (size=%d)\n", l); - return; - } - // recalculate the ppp frame length sizeppp = l - (ETH_HLEN + sizeof(*hdr)); hdr->length = htons(sizeppp);