From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Olaf Hering <olaf@aepfle.de>
Cc: xen-devel@lists.xen.org, Ian Jackson <ian.jackson@eu.citrix.com>,
Ian Campbell <ian.campbell@citrix.com>,
Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Subject: Re: [PATCH] stubdom: fix lwip compile
Date: Wed, 17 Sep 2014 11:47:40 +0200 [thread overview]
Message-ID: <20140917094740.GQ3064@type.bordeaux.inria.fr> (raw)
In-Reply-To: <1410946869-23476-1-git-send-email-olaf@aepfle.de>
Olaf Hering, le Wed 17 Sep 2014 11:41:09 +0200, a écrit :
> stubdom/lwip-x86_64/src/core/dhcp.c: In function 'dhcp_create_request':
> stubdom/lwip-x86_64/src/core/dhcp.c:1359:71: error: array subscript is above array bounds [-Werror=array-bounds]
> dhcp->msg_out->chaddr[i] = (i < netif->hwaddr_len) ? netif->hwaddr[i] : 0/* pad byte*/;
>
> gcc-4.8 can not know if hwaddr_len exceeds the hwaddr array size,
> so force an upper limit to assist gcc.
>
> Signed-off-by: Olaf Hering <olaf@aepfle.de>
That seems like the most reasonable and efficient solution indeed.
Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
> ---
> stubdom/Makefile | 1 +
> stubdom/lwip.dhcp_create_request-hwaddr_len.patch | 26 +++++++++++++++++++++++
> 2 files changed, 27 insertions(+)
> create mode 100644 stubdom/lwip.dhcp_create_request-hwaddr_len.patch
>
> diff --git a/stubdom/Makefile b/stubdom/Makefile
> index 6bea68b..88da991 100644
> --- a/stubdom/Makefile
> +++ b/stubdom/Makefile
> @@ -145,6 +145,7 @@ lwip-$(XEN_TARGET_ARCH): lwip-$(LWIP_VERSION).tar.gz
> tar xzf $<
> mv lwip $@
> patch -d $@ -p0 < lwip.patch-cvs
> + patch -d $@ -p0 < lwip.dhcp_create_request-hwaddr_len.patch
> touch $@
>
> #############
> diff --git a/stubdom/lwip.dhcp_create_request-hwaddr_len.patch b/stubdom/lwip.dhcp_create_request-hwaddr_len.patch
> new file mode 100644
> index 0000000..12f1014
> --- /dev/null
> +++ b/stubdom/lwip.dhcp_create_request-hwaddr_len.patch
> @@ -0,0 +1,26 @@
> +---
> + lwip-x86_64/src/core/dhcp.c | 4 +++-
> + 1 file changed, 3 insertions(+), 1 deletion(-)
> +
> +Index: src/core/dhcp.c
> +===================================================================
> +--- src/core/dhcp.c
> ++++ src/core/dhcp.c
> +@@ -1322,6 +1322,8 @@ dhcp_create_request(struct netif *netif)
> + {
> + struct dhcp *dhcp;
> + u16_t i;
> ++ /* gcc can not know if hwaddr_len exceeds the hwaddr array size */
> ++ u8_t hwaddr_len = netif->hwaddr_len > NETIF_MAX_HWADDR_LEN ? NETIF_MAX_HWADDR_LEN : netif->hwaddr_len;
> + LWIP_ERROR("dhcp_create_request: netif != NULL", (netif != NULL), return ERR_ARG;);
> + dhcp = netif->dhcp;
> + LWIP_ERROR("dhcp_create_request: dhcp != NULL", (dhcp != NULL), return ERR_VAL;);
> +@@ -1356,7 +1358,7 @@ dhcp_create_request(struct netif *netif)
> + dhcp->msg_out->giaddr.addr = 0;
> + for (i = 0; i < DHCP_CHADDR_LEN; i++) {
> + /* copy netif hardware address, pad with zeroes */
> +- dhcp->msg_out->chaddr[i] = (i < netif->hwaddr_len) ? netif->hwaddr[i] : 0/* pad byte*/;
> ++ dhcp->msg_out->chaddr[i] = (i < hwaddr_len) ? netif->hwaddr[i] : 0/* pad byte*/;
> + }
> + for (i = 0; i < DHCP_SNAME_LEN; i++) {
> + dhcp->msg_out->sname[i] = 0;
>
--
Samuel
"I once witnessed a long-winded, month-long flamewar over the use of
mice vs. trackballs...It was very silly."
(By Matt Welsh)
prev parent reply other threads:[~2014-09-17 9:47 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-17 9:41 [PATCH] stubdom: fix lwip compile Olaf Hering
2014-09-17 9:47 ` Samuel Thibault [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140917094740.GQ3064@type.bordeaux.inria.fr \
--to=samuel.thibault@ens-lyon.org \
--cc=ian.campbell@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=olaf@aepfle.de \
--cc=stefano.stabellini@eu.citrix.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).