From: Jason Ish Date: Tue, 26 Mar 2019 22:28:17 +0000 (-0600) Subject: mpls: fix misaligned read X-Git-Tag: suricata-5.0.0-beta1~40 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=164fb7189898893ff0b2ace957c7cec19d0ee88a;p=thirdparty%2Fsuricata.git mpls: fix misaligned read Instead of casting the packet buffer to a uint32, memcpy it to avoid misaligned read error, as caught by the undefined behavior detector (ubsan). Redmine issue: https://redmine.openinfosecfoundation.org/issues/2903 --- diff --git a/src/decode-mpls.c b/src/decode-mpls.c index 53d7ec1882..e5bcea39f6 100644 --- a/src/decode-mpls.c +++ b/src/decode-mpls.c @@ -58,7 +58,7 @@ int DecodeMPLS(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt, ENGINE_SET_INVALID_EVENT(p, MPLS_HEADER_TOO_SMALL); return TM_ECODE_FAILED; } - shim = *(uint32_t *)pkt; + memcpy(&shim, pkt, sizeof(shim)); pkt += MPLS_HEADER_LEN; len -= MPLS_HEADER_LEN; } while (MPLS_BOTTOM(shim) == 0);