From 164fb7189898893ff0b2ace957c7cec19d0ee88a Mon Sep 17 00:00:00 2001 From: Jason Ish Date: Tue, 26 Mar 2019 16:28:17 -0600 Subject: [PATCH] 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 --- src/decode-mpls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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);