]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
Fix an unaligned access when chassis ID is an IP address.
authorVincent Bernat <bernat@luffy.cx>
Wed, 12 May 2010 09:57:11 +0000 (11:57 +0200)
committerVincent Bernat <bernat@luffy.cx>
Wed, 12 May 2010 09:57:58 +0000 (11:57 +0200)
src/display.c

index c16d69fee0f612f0e7e71b6866e44be596945f9f..5a7fbbf23b94b5180fe0baa0204acc7603ca7b51 100644 (file)
@@ -735,6 +735,8 @@ static void
 display_chassis(struct writer * w, struct lldpd_chassis *chassis)
 {
        char *cid;
+       struct in_addr ip;
+
        if ((cid = (char *)malloc(chassis->c_id_len + 1)) == NULL)
                fatal(NULL);
        memcpy(cid, chassis->c_id, chassis->c_id_len);
@@ -755,7 +757,8 @@ display_chassis(struct writer * w, struct lldpd_chassis *chassis)
                break;
        case LLDP_CHASSISID_SUBTYPE_ADDR:
                if (*(u_int8_t*)chassis->c_id == 1) {
-                       tag_data(w, inet_ntoa(*(struct in_addr*)(chassis->c_id + 1)));
+                       memcpy(&ip, chassis->c_id + 1, sizeof(struct in_addr));
+                       tag_data(w, inet_ntoa(ip));
                        break;
                }
        case LLDP_CHASSISID_SUBTYPE_PORT: