Skip to content

Commit 7173b47

Browse files
committed
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)
1 parent e47683a commit 7173b47

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/channel.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,14 @@ channel_open(
710710
channel_free(channel);
711711
return NULL;
712712
}
713-
memcpy((char *)&server.sin_addr, host->h_addr, host->h_length);
713+
{
714+
char *p;
715+
716+
/* When using host->h_addr directly ubsan warns for it to not be
717+
* aligned. First copy the pointer to aviod that. */
718+
memcpy(&p, &host->h_addr, sizeof(p));
719+
memcpy((char *)&server.sin_addr, p, host->h_length);
720+
}
714721

715722
/* On Mac and Solaris a zero timeout almost never works. At least wait
716723
* one millisecond. Let's do it for all systems, because we don't know why

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,8 @@ static char *(features[]) =
764764

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
183,
767769
/**/
768770
182,
769771
/**/

0 commit comments

Comments
 (0)