diff options
author | Bram Moolenaar <Bram@vim.org> | 2017-01-14 17:04:38 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2017-01-14 17:04:38 +0100 |
commit | 7173b47958a238bb07f80b8f26fb232b0ea69b4a (patch) | |
tree | 3573adaedc038f24b6b4ff939b8b582dbe8608c0 /src/channel.c | |
parent | e47683a0913f102b6ae08c8848d5aa675d99b188 (diff) |
patch 8.0.0183: ubsan warns for unaligned addressv8.0.0183
Problem: Ubsan warns for using a pointer that is not aligned.
Solution: First copy the address. (Yegappan Lakshmanan)
Diffstat (limited to 'src/channel.c')
-rw-r--r-- | src/channel.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/channel.c b/src/channel.c index f522e80c4a..bd31bf3cba 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 |