From a71eb083aec8e32258c141975315112dd1b4e2ad Mon Sep 17 00:00:00 2001 From: Michael Tuexen <tuexen@epyc.nplab.de> Date: Fri, 5 Oct 2018 14:21:09 +0200 Subject: [PATCH] Avoid undefined behaviour. --- gtests/net/packetdrill/packet_socket_linux.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gtests/net/packetdrill/packet_socket_linux.c b/gtests/net/packetdrill/packet_socket_linux.c index a31873a2..d8ec4d76 100644 --- a/gtests/net/packetdrill/packet_socket_linux.c +++ b/gtests/net/packetdrill/packet_socket_linux.c @@ -168,12 +168,12 @@ void packet_socket_set_filter(struct packet_socket *psock, } /* Fill in the client-side ethernet address to look for. */ - bpfcode.filter[1].k = ((client_ether[2] << 24) | - (client_ether[3] << 16) | - (client_ether[4] << 8) | - (client_ether[5])); - bpfcode.filter[3].k = ((client_ether[0] << 8) | - (client_ether[1])); + bpfcode.filter[1].k = (((u32)client_ether[2] << 24) | + ((u32)client_ether[3] << 16) | + ((u32)client_ether[4] << 8) | + ((u32)client_ether[5])); + bpfcode.filter[3].k = (((u32)client_ether[0] << 8) | + ((u32(client_ether[1])); if (debug_logging) { int i; -- GitLab