From: Vladimir 'phcoder' Serbinenko Date: Tue, 13 Dec 2011 01:15:09 +0000 (+0100) Subject: * grub-core/net/netbuff.c (grub_netbuff_alloc): Ensure proper alignment. X-Git-Tag: 2.00~903 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f138623a601f3fffd09e8a2c21cff36566948319;p=thirdparty%2Fgrub.git * grub-core/net/netbuff.c (grub_netbuff_alloc): Ensure proper alignment. --- diff --git a/ChangeLog b/ChangeLog index b7a5b02f3..be4b26ba2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-12-13 Vladimir Serbinenko + + * grub-core/net/netbuff.c (grub_netbuff_alloc): Ensure proper alignment. + 2011-12-13 Vladimir Serbinenko * grub-core/disk/mdraid_linux.c (grub_mdraid_detect): Change pointer diff --git a/grub-core/net/netbuff.c b/grub-core/net/netbuff.c index d20104ab0..bee207f90 100644 --- a/grub-core/net/netbuff.c +++ b/grub-core/net/netbuff.c @@ -78,6 +78,8 @@ grub_netbuff_alloc (grub_size_t len) struct grub_net_buff *nb; void *data; + COMPILE_TIME_ASSERT (NETBUFF_ALIGN % sizeof (grub_properly_aligned_t) == 0); + if (len < NETBUFFMINLEN) len = NETBUFFMINLEN; @@ -85,7 +87,8 @@ grub_netbuff_alloc (grub_size_t len) data = grub_memalign (NETBUFF_ALIGN, len + sizeof (*nb)); if (!data) return NULL; - nb = (struct grub_net_buff *) ((grub_uint8_t *) data + len); + nb = (struct grub_net_buff *) ((grub_properly_aligned_t *) data + + len / sizeof (grub_properly_aligned_t)); nb->head = nb->data = nb->tail = data; nb->end = (char *) nb; return nb;