From: Vincent Bernat Date: Wed, 12 May 2010 09:57:11 +0000 (+0200) Subject: Fix an unaligned access when chassis ID is an IP address. X-Git-Tag: 0.5.1~13 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=dd098289040b621aaab44e2d54ef28f1b8342f95;p=thirdparty%2Flldpd.git Fix an unaligned access when chassis ID is an IP address. --- diff --git a/src/display.c b/src/display.c index c16d69fe..5a7fbbf2 100644 --- a/src/display.c +++ b/src/display.c @@ -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: