]> granicus.if.org Git - vim/commitdiff
patch 8.0.0183: ubsan warns for unaligned address v8.0.0183
authorBram Moolenaar <Bram@vim.org>
Sat, 14 Jan 2017 16:04:38 +0000 (17:04 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 14 Jan 2017 16:04:38 +0000 (17:04 +0100)
Problem:    Ubsan warns for using a pointer that is not aligned.
Solution:   First copy the address. (Yegappan Lakshmanan)

src/channel.c
src/version.c

index f522e80c4ae323fb2ddd74a9aa922c969fde8acb..bd31bf3cbad55d61026bc341f6d4eef9b0ce1024 100644 (file)
@@ -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
index 806e86511a815fb713d76b76aa5c6940e6567b9c..562757a722f0e02a1b7b652de9453f346d99aff7 100644 (file)
@@ -764,6 +764,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    183,
 /**/
     182,
 /**/