]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
lldpd: fix an alignment (non-)issue
authorVincent Bernat <bernat@luffy.cx>
Thu, 6 Jun 2013 20:38:43 +0000 (22:38 +0200)
committerVincent Bernat <bernat@luffy.cx>
Thu, 6 Jun 2013 20:38:43 +0000 (22:38 +0200)
src/daemon/lldpd.c

index 2431d683424b36f1a9d4611a0248ee90cb69ff86..7924e838adf838cadd68fa998cff17e6f949a0d1 100644 (file)
@@ -378,8 +378,11 @@ lldpd_decode(struct lldpd *cfg, char *frame, int s,
        if (s < sizeof(struct ether_header) + 4)
                /* Too short, just discard it */
                return;
+
        /* Decapsulate VLAN frames */
-       if (((struct ether_header*)frame)->ether_type == htons(ETHERTYPE_VLAN)) {
+       struct ether_header eheader;
+       memcpy(&eheader, frame, sizeof(struct ether_header));
+       if (eheader.ether_type == htons(ETHERTYPE_VLAN)) {
                /* VLAN decapsulation means to shift 4 bytes left the frame from
                 * offset 2*ETHER_ADDR_LEN */
                memmove(frame + 2*ETHER_ADDR_LEN, frame + 2*ETHER_ADDR_LEN + 4, s - 2*ETHER_ADDR_LEN);