Commit 81342497 authored by Antonin Décimo's avatar Antonin Décimo Committed by Juliusz Chroboczek

Prevent unspecified behaviour when zeroing union.

The C standard (§J.1-1) reads:
> The following [is] unspecified
> — The value of a union member other than the last one stored into (6.2.6.1).

Zero-ing the `raw` member first makes the value of the `nh` member
unspecified. It’s better to zeroise the whole union.
parent de74c07b
......@@ -508,7 +508,7 @@ netlink_send_dump(int type, void *data, int len) {
iov[1].iov_base = data;
iov[1].iov_len = len;
memset(buf.raw, 0, sizeof(buf.raw));
memset(&buf, 0, sizeof(buf));
buf.nh.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST;
buf.nh.nlmsg_type = type;
buf.nh.nlmsg_seq = ++nl_command.seqno;
......@@ -1038,7 +1038,7 @@ kernel_route(int operation, int table,
if(metric >= KERNEL_INFINITY && (plen == 0 || (ipv4 && plen == 96)))
return 0;
memset(buf.raw, 0, sizeof(buf.raw));
memset(&buf, 0, sizeof(buf));
if(operation == ROUTE_ADD) {
buf.nh.nlmsg_flags = NLM_F_REQUEST | NLM_F_CREATE | NLM_F_EXCL;
buf.nh.nlmsg_type = RTM_NEWROUTE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment