summaryrefslogtreecommitdiff
path: root/accel-pppd/ctrl/sstp
diff options
context:
space:
mode:
authorVolodymyr Huti <volodymyr.huti@gmail.com>2022-10-13 14:20:06 +0300
committerVolodymyr Huti <volodymyr.huti@gmail.com>2022-10-22 15:11:29 +0300
commit6e5f9980a8a71015a228279e07970621d23c7b35 (patch)
tree73ae1d6596a175c76a0d24867592a4016c0592c5 /accel-pppd/ctrl/sstp
parent2b865db72bc2ddc6411950d72f1c23e8ef115b8a (diff)
downloadaccel-ppp-6e5f9980a8a71015a228279e07970621d23c7b35.tar.gz
accel-ppp-6e5f9980a8a71015a228279e07970621d23c7b35.zip
T72: Fix compilations warnings for unaligned variable access
- IPoE/DHCP4: Specify minimal suitable alignment explicitly. We need to guarantee 2 byte alignment for the `hdr` pointer in `ip_csum(uint16_t *buf)` calculation - PPPOE: Suppress false-positive warning for `sockaddr_pppox`. Similiar issue: https://github.com/kernelslacker/trinity/pull/40 - Introduce tmp variables to avoid alignment issues for SSTP/DHCPv6 For additional details: https://phabricator.accel-ppp.org/T72 Signed-off-by: Volodymyr Huti <v.huti@vyos.io>
Diffstat (limited to 'accel-pppd/ctrl/sstp')
-rw-r--r--accel-pppd/ctrl/sstp/sstp.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/accel-pppd/ctrl/sstp/sstp.c b/accel-pppd/ctrl/sstp/sstp.c
index 40c6ad91..a97f4ec5 100644
--- a/accel-pppd/ctrl/sstp/sstp.c
+++ b/accel-pppd/ctrl/sstp/sstp.c
@@ -286,12 +286,15 @@ static int _vstrsep(char *buf, const char *sep, ...)
static in_addr_t sockaddr_ipv4(struct sockaddr_t *addr)
{
+ struct in6_addr inaddr6;
+
switch (addr->u.sa.sa_family) {
case AF_INET:
return addr->u.sin.sin_addr.s_addr;
case AF_INET6:
- if (IN6_IS_ADDR_V4MAPPED(&addr->u.sin6.sin6_addr))
- return addr->u.sin6.sin6_addr.s6_addr32[3];
+ inaddr6 = addr->u.sin6.sin6_addr;
+ if (IN6_IS_ADDR_V4MAPPED(&inaddr6))
+ return inaddr6.s6_addr32[3];
/* fall through */
default:
return INADDR_ANY;
@@ -301,22 +304,22 @@ static in_addr_t sockaddr_ipv4(struct sockaddr_t *addr)
static int sockaddr_ntop(struct sockaddr_t *addr, char *dst, socklen_t size, int flags)
{
char ipv6_buf[INET6_ADDRSTRLEN], *path, sign;
+ struct sockaddr_in6 sin6 = addr->u.sin6;
+ struct in6_addr inaddr6 = sin6.sin6_addr;
switch (addr->u.sa.sa_family) {
case AF_INET:
return snprintf(dst, size, (flags & FLAG_NOPORT) ? "%s" : "%s:%d",
inet_ntoa(addr->u.sin.sin_addr), ntohs(addr->u.sin.sin_port));
case AF_INET6:
- if (IN6_IS_ADDR_V4MAPPED(&addr->u.sin6.sin6_addr)) {
- inet_ntop(AF_INET, &addr->u.sin6.sin6_addr.s6_addr32[3],
- ipv6_buf, sizeof(ipv6_buf));
+ if (IN6_IS_ADDR_V4MAPPED(&inaddr6)) {
+ inet_ntop(AF_INET, &inaddr6.s6_addr32[3], ipv6_buf, sizeof(ipv6_buf));
return snprintf(dst, size, (flags & FLAG_NOPORT) ? "%s" : "%s:%d",
- ipv6_buf, ntohs(addr->u.sin6.sin6_port));
+ ipv6_buf, ntohs(sin6.sin6_port));
} else {
- inet_ntop(AF_INET6, &addr->u.sin6.sin6_addr,
- ipv6_buf, sizeof(ipv6_buf));
+ inet_ntop(AF_INET6, &inaddr6, ipv6_buf, sizeof(ipv6_buf));
return snprintf(dst, size, (flags & FLAG_NOPORT) ? "%s" : "[%s]:%d",
- ipv6_buf, ntohs(addr->u.sin6.sin6_port));
+ ipv6_buf, ntohs(sin6.sin6_port));
}
case AF_UNIX:
if (addr->len <= offsetof(typeof(addr->u.sun), sun_path)) {
@@ -2276,12 +2279,14 @@ static int sstp_connect(struct triton_md_handler_t *h)
struct sstp_conn_t *conn;
struct sockaddr_t addr;
char addr_buf[ADDRSTR_MAXLEN];
+ socklen_t addrlen;
in_addr_t ip;
int sock, value;
while (1) {
- addr.len = sizeof(addr.u);
- sock = accept(h->fd, &addr.u.sa, &addr.len);
+ addrlen = sizeof(addr.u);
+ sock = accept(h->fd, &addr.u.sa, &addrlen);
+ addr.len = addrlen;
if (sock < 0) {
if (errno == EAGAIN)
return 0;
@@ -2408,8 +2413,8 @@ static int sstp_connect(struct triton_md_handler_t *h)
sockaddr_ntop(&addr, addr_buf, sizeof(addr_buf), FLAG_NOPORT);
conn->ctrl.calling_station_id = _strdup(addr_buf);
- addr.len = sizeof(addr.u);
- getsockname(sock, &addr.u.sa, &addr.len);
+ addrlen = sizeof(addr.u);
+ getsockname(sock, &addr.u.sa, &addrlen);
sockaddr_ntop(&addr, addr_buf, sizeof(addr_buf), FLAG_NOPORT);
conn->ctrl.called_station_id = _strdup(addr_buf);