mirror of
https://github.com/oasislinux/oasis.git
synced 2026-05-23 11:24:19 +02:00
158 lines
5.3 KiB
Diff
158 lines
5.3 KiB
Diff
From 87e689570abaabf8ffaff0682a4fa4d528fab2ce Mon Sep 17 00:00:00 2001
|
|
From: Michael Forney <mforney@mforney.org>
|
|
Date: Tue, 12 Mar 2019 19:12:31 -0700
|
|
Subject: [PATCH] Avoid pointer arithmetic on `void *`
|
|
|
|
---
|
|
include/libnetlink.h | 4 ++--
|
|
ip/ipfou.c | 2 +-
|
|
ip/ipila.c | 2 +-
|
|
ip/ipseg6.c | 2 +-
|
|
ip/tcp_metrics.c | 2 +-
|
|
lib/libnetlink.c | 12 ++++++------
|
|
lib/utils.c | 2 +-
|
|
7 files changed, 13 insertions(+), 13 deletions(-)
|
|
|
|
diff --git a/include/libnetlink.h b/include/libnetlink.h
|
|
index 8ebdc6d3..ff5d92fa 100644
|
|
--- a/include/libnetlink.h
|
|
+++ b/include/libnetlink.h
|
|
@@ -169,7 +169,7 @@ struct rtattr *rta_nest(struct rtattr *rta, int maxlen, int type);
|
|
int rta_nest_end(struct rtattr *rta, struct rtattr *nest);
|
|
|
|
#define RTA_TAIL(rta) \
|
|
- ((struct rtattr *) (((void *) (rta)) + \
|
|
+ ((struct rtattr *) (((char *) (rta)) + \
|
|
RTA_ALIGN((rta)->rta_len)))
|
|
|
|
#define parse_rtattr_nested(tb, max, rta) \
|
|
@@ -232,7 +232,7 @@ int rtnl_from_file(FILE *, rtnl_listen_filter_t handler,
|
|
void *jarg);
|
|
|
|
#define NLMSG_TAIL(nmsg) \
|
|
- ((struct rtattr *) (((void *) (nmsg)) + NLMSG_ALIGN((nmsg)->nlmsg_len)))
|
|
+ ((struct rtattr *) (((char *) (nmsg)) + NLMSG_ALIGN((nmsg)->nlmsg_len)))
|
|
|
|
#ifndef IFA_RTA
|
|
#define IFA_RTA(r) \
|
|
diff --git a/ip/ipfou.c b/ip/ipfou.c
|
|
index ea126b08..f24586d4 100644
|
|
--- a/ip/ipfou.c
|
|
+++ b/ip/ipfou.c
|
|
@@ -228,7 +228,7 @@ static int print_fou_mapping(struct nlmsghdr *n, void *arg)
|
|
return -1;
|
|
|
|
ghdr = NLMSG_DATA(n);
|
|
- parse_rtattr(tb, FOU_ATTR_MAX, (void *) ghdr + GENL_HDRLEN, len);
|
|
+ parse_rtattr(tb, FOU_ATTR_MAX, (struct rtattr *)((char *)ghdr + GENL_HDRLEN), len);
|
|
|
|
open_json_object(NULL);
|
|
if (tb[FOU_ATTR_PORT])
|
|
diff --git a/ip/ipila.c b/ip/ipila.c
|
|
index 739ee4e1..50c8c300 100644
|
|
--- a/ip/ipila.c
|
|
+++ b/ip/ipila.c
|
|
@@ -95,7 +95,7 @@ static int print_ila_mapping(struct nlmsghdr *n, void *arg)
|
|
return -1;
|
|
|
|
ghdr = NLMSG_DATA(n);
|
|
- parse_rtattr(tb, ILA_ATTR_MAX, (void *) ghdr + GENL_HDRLEN, len);
|
|
+ parse_rtattr(tb, ILA_ATTR_MAX, (struct rtattr *)((char *)ghdr + GENL_HDRLEN), len);
|
|
|
|
open_json_object(NULL);
|
|
print_ila_locid("locator_match", ILA_ATTR_LOCATOR_MATCH, tb);
|
|
diff --git a/ip/ipseg6.c b/ip/ipseg6.c
|
|
index 56a76996..1c3c3bf5 100644
|
|
--- a/ip/ipseg6.c
|
|
+++ b/ip/ipseg6.c
|
|
@@ -115,7 +115,7 @@ static int process_msg(struct nlmsghdr *n, void *arg)
|
|
|
|
ghdr = NLMSG_DATA(n);
|
|
|
|
- parse_rtattr(attrs, SEG6_ATTR_MAX, (void *)ghdr + GENL_HDRLEN, len);
|
|
+ parse_rtattr(attrs, SEG6_ATTR_MAX, (struct rtattr *)((char *)ghdr + GENL_HDRLEN), len);
|
|
|
|
open_json_object(NULL);
|
|
switch (ghdr->cmd) {
|
|
diff --git a/ip/tcp_metrics.c b/ip/tcp_metrics.c
|
|
index acbd745a..051ddc63 100644
|
|
--- a/ip/tcp_metrics.c
|
|
+++ b/ip/tcp_metrics.c
|
|
@@ -178,7 +178,7 @@ static int process_msg(struct nlmsghdr *n, void *arg)
|
|
if (ghdr->cmd != TCP_METRICS_CMD_GET)
|
|
return 0;
|
|
|
|
- parse_rtattr(attrs, TCP_METRICS_ATTR_MAX, (void *) ghdr + GENL_HDRLEN,
|
|
+ parse_rtattr(attrs, TCP_METRICS_ATTR_MAX, (struct rtattr *)((char *)ghdr + GENL_HDRLEN),
|
|
len);
|
|
|
|
if (attrs[TCP_METRICS_ATTR_ADDR_IPV4]) {
|
|
diff --git a/lib/libnetlink.c b/lib/libnetlink.c
|
|
index e02d6294..48b19501 100644
|
|
--- a/lib/libnetlink.c
|
|
+++ b/lib/libnetlink.c
|
|
@@ -1280,7 +1280,7 @@ int addraw_l(struct nlmsghdr *n, int maxlen, const void *data, int len)
|
|
}
|
|
|
|
memcpy(NLMSG_TAIL(n), data, len);
|
|
- memset((void *) NLMSG_TAIL(n) + len, 0, NLMSG_ALIGN(len) - len);
|
|
+ memset((char *) NLMSG_TAIL(n) + len, 0, NLMSG_ALIGN(len) - len);
|
|
n->nlmsg_len = NLMSG_ALIGN(n->nlmsg_len) + NLMSG_ALIGN(len);
|
|
return 0;
|
|
}
|
|
@@ -1295,7 +1295,7 @@ struct rtattr *addattr_nest(struct nlmsghdr *n, int maxlen, int type)
|
|
|
|
int addattr_nest_end(struct nlmsghdr *n, struct rtattr *nest)
|
|
{
|
|
- nest->rta_len = (void *)NLMSG_TAIL(n) - (void *)nest;
|
|
+ nest->rta_len = (char *)NLMSG_TAIL(n) - (char *)nest;
|
|
return n->nlmsg_len;
|
|
}
|
|
|
|
@@ -1311,9 +1311,9 @@ struct rtattr *addattr_nest_compat(struct nlmsghdr *n, int maxlen, int type,
|
|
|
|
int addattr_nest_compat_end(struct nlmsghdr *n, struct rtattr *start)
|
|
{
|
|
- struct rtattr *nest = (void *)start + NLMSG_ALIGN(start->rta_len);
|
|
+ struct rtattr *nest = (struct rtattr *)((char *)start + NLMSG_ALIGN(start->rta_len));
|
|
|
|
- start->rta_len = (void *)NLMSG_TAIL(n) - (void *)start;
|
|
+ start->rta_len = (char *)NLMSG_TAIL(n) - (char *)start;
|
|
addattr_nest_end(n, nest);
|
|
return n->nlmsg_len;
|
|
}
|
|
@@ -1385,7 +1385,7 @@ struct rtattr *rta_nest(struct rtattr *rta, int maxlen, int type)
|
|
|
|
int rta_nest_end(struct rtattr *rta, struct rtattr *nest)
|
|
{
|
|
- nest->rta_len = (void *)RTA_TAIL(rta) - (void *)nest;
|
|
+ nest->rta_len = (char *)RTA_TAIL(rta) - (char *)nest;
|
|
|
|
return rta->rta_len;
|
|
}
|
|
@@ -1434,7 +1434,7 @@ int __parse_rtattr_nested_compat(struct rtattr *tb[], int max,
|
|
if (RTA_PAYLOAD(rta) < len)
|
|
return -1;
|
|
if (RTA_PAYLOAD(rta) >= RTA_ALIGN(len) + sizeof(struct rtattr)) {
|
|
- rta = RTA_DATA(rta) + RTA_ALIGN(len);
|
|
+ rta = (struct rtattr *)((char *)RTA_DATA(rta) + RTA_ALIGN(len));
|
|
return parse_rtattr_nested(tb, max, rta);
|
|
}
|
|
memset(tb, 0, sizeof(struct rtattr *) * (max + 1));
|
|
diff --git a/lib/utils.c b/lib/utils.c
|
|
index c6f19ce1..d02bc32d 100644
|
|
--- a/lib/utils.c
|
|
+++ b/lib/utils.c
|
|
@@ -1532,7 +1532,7 @@ int get_rtnl_link_stats_rta(struct rtnl_link_stats64 *stats64,
|
|
|
|
len = RTA_PAYLOAD(rta);
|
|
if (len < size)
|
|
- memset(s + len, 0, size - len);
|
|
+ memset((char *)s + len, 0, size - len);
|
|
else
|
|
len = size;
|
|
|
|
--
|
|
2.25.0
|
|
|