From f138623a601f3fffd09e8a2c21cff36566948319 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 13 Dec 2011 02:15:09 +0100 Subject: [PATCH] * grub-core/net/netbuff.c (grub_netbuff_alloc): Ensure proper alignment. --- ChangeLog | 4 ++++ grub-core/net/netbuff.c | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) 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;