aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2005-06-28 15:54:43 -0400
committerDavid S. Miller <davem@davemloft.net>2005-06-28 15:54:43 -0400
commitb3563c4fbff906991a1b4ef4609f99cca2a0de6a (patch)
treee5c0e4cb4a0a48ebeeb8b1515128c115c5aa528c
parent4095ebf1e641b0f37ee1cd04c903bb85cf4ed25b (diff)
[NETLINK]: Clear padding in netlink messages
Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/linux/netlink.h1
-rw-r--r--include/linux/rtnetlink.h5
-rw-r--r--net/core/rtnetlink.c1
3 files changed, 6 insertions, 1 deletions
diff --git a/include/linux/netlink.h b/include/linux/netlink.h
index 3029cad63a01..27e4d164a108 100644
--- a/include/linux/netlink.h
+++ b/include/linux/netlink.h
@@ -168,6 +168,7 @@ __nlmsg_put(struct sk_buff *skb, u32 pid, u32 seq, int type, int len, int flags)
168 nlh->nlmsg_flags = flags; 168 nlh->nlmsg_flags = flags;
169 nlh->nlmsg_pid = pid; 169 nlh->nlmsg_pid = pid;
170 nlh->nlmsg_seq = seq; 170 nlh->nlmsg_seq = seq;
171 memset(NLMSG_DATA(nlh) + len, 0, NLMSG_ALIGN(size) - size);
171 return nlh; 172 return nlh;
172} 173}
173 174
diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h
index d021888b58f1..dc26e82ba0fd 100644
--- a/include/linux/rtnetlink.h
+++ b/include/linux/rtnetlink.h
@@ -898,7 +898,9 @@ extern void __rta_fill(struct sk_buff *skb, int attrtype, int attrlen, const voi
898 memcpy(skb_put(skb, attrlen), data, attrlen); }) 898 memcpy(skb_put(skb, attrlen), data, attrlen); })
899 899
900#define RTA_PUT_NOHDR(skb, attrlen, data) \ 900#define RTA_PUT_NOHDR(skb, attrlen, data) \
901 RTA_APPEND(skb, RTA_ALIGN(attrlen), data) 901({ RTA_APPEND(skb, RTA_ALIGN(attrlen), data); \
902 memset(skb->tail - (RTA_ALIGN(attrlen) - attrlen), 0, \
903 RTA_ALIGN(attrlen) - attrlen); })
902 904
903#define RTA_PUT_U8(skb, attrtype, value) \ 905#define RTA_PUT_U8(skb, attrtype, value) \
904({ u8 _tmp = (value); \ 906({ u8 _tmp = (value); \
@@ -978,6 +980,7 @@ __rta_reserve(struct sk_buff *skb, int attrtype, int attrlen)
978 rta = (struct rtattr*)skb_put(skb, RTA_ALIGN(size)); 980 rta = (struct rtattr*)skb_put(skb, RTA_ALIGN(size));
979 rta->rta_type = attrtype; 981 rta->rta_type = attrtype;
980 rta->rta_len = size; 982 rta->rta_len = size;
983 memset(RTA_DATA(rta) + attrlen, 0, RTA_ALIGN(size) - size);
981 return rta; 984 return rta;
982} 985}
983 986
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index e013d836a7ab..879237c378f8 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -126,6 +126,7 @@ void __rta_fill(struct sk_buff *skb, int attrtype, int attrlen, const void *data
126 rta->rta_type = attrtype; 126 rta->rta_type = attrtype;
127 rta->rta_len = size; 127 rta->rta_len = size;
128 memcpy(RTA_DATA(rta), data, attrlen); 128 memcpy(RTA_DATA(rta), data, attrlen);
129 memset(RTA_DATA(rta) + attrlen, 0, RTA_ALIGN(size) - size);
129} 130}
130 131
131size_t rtattr_strlcpy(char *dest, const struct rtattr *rta, size_t size) 132size_t rtattr_strlcpy(char *dest, const struct rtattr *rta, size_t size)