]> xenbits.xensource.com Git - people/liuw/stubdom.git/commitdiff
stubdom: fix lwip compile
authorOlaf Hering <olaf@aepfle.de>
Mon, 22 Sep 2014 12:59:50 +0000 (14:59 +0200)
committerIan Campbell <ian.campbell@citrix.com>
Tue, 23 Sep 2014 09:11:55 +0000 (10:11 +0100)
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 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>
Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Makefile
lwip.dhcp_create_request-hwaddr_len.patch [new file with mode: 0644]

index 6bea68b1d381cca3c7c38ed83d0b4fb8562cb855..88da991b1b66946ccaef26629cd2e4e87ffd0cbf 100644 (file)
--- a/Makefile
+++ b/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/lwip.dhcp_create_request-hwaddr_len.patch b/lwip.dhcp_create_request-hwaddr_len.patch
new file mode 100644 (file)
index 0000000..12f1014
--- /dev/null
@@ -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;