From 7173b47958a238bb07f80b8f26fb232b0ea69b4a Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 14 Jan 2017 17:04:38 +0100 Subject: [PATCH] patch 8.0.0183: ubsan warns for unaligned address Problem: Ubsan warns for using a pointer that is not aligned. Solution: First copy the address. (Yegappan Lakshmanan) --- src/channel.c | 9 ++++++++- src/version.c | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/channel.c b/src/channel.c index f522e80c4..bd31bf3cb 100644 --- a/src/channel.c +++ b/src/channel.c @@ -710,7 +710,14 @@ channel_open( channel_free(channel); return NULL; } - memcpy((char *)&server.sin_addr, host->h_addr, host->h_length); + { + char *p; + + /* When using host->h_addr directly ubsan warns for it to not be + * aligned. First copy the pointer to aviod that. */ + memcpy(&p, &host->h_addr, sizeof(p)); + memcpy((char *)&server.sin_addr, p, host->h_length); + } /* On Mac and Solaris a zero timeout almost never works. At least wait * one millisecond. Let's do it for all systems, because we don't know why diff --git a/src/version.c b/src/version.c index 806e86511..562757a72 100644 --- a/src/version.c +++ b/src/version.c @@ -764,6 +764,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 183, /**/ 182, /**/ -- 2.50.1