All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH for-xen-4.5] stubdom: another for fix for lwip compile
@ 2014-10-07 14:15 Olaf Hering
  2014-10-07 16:18 ` Samuel Thibault
  0 siblings, 1 reply; 3+ messages in thread
From: Olaf Hering @ 2014-10-07 14:15 UTC (permalink / raw)
  To: xen-devel; +Cc: Samuel Thibault, Olaf Hering, Stefano Stabellini

stubdom/lwip-x86_64/src/core/dhcp.c: In function 'dhcp_create_request':
stubdom/lwip-x86_64/src/core/dhcp.c:1361:64: error: array subscript is above array bounds

The previous attempt to fix the failure above worked fine in SLE11,
openSUSE 13.1 and newer. But gcc-4.5 as included in openSUSE 11.4 still
failed to compile. To fix compilation also with this version of gcc move
the range check right into the code instead of assigning it to a
temporary variable.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Cc: Samuel Thibault <samuel.thibault@ens-lyon.org>
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
 stubdom/lwip.dhcp_create_request-hwaddr_len.patch | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/stubdom/lwip.dhcp_create_request-hwaddr_len.patch b/stubdom/lwip.dhcp_create_request-hwaddr_len.patch
index 12f1014..c43f282 100644
--- a/stubdom/lwip.dhcp_create_request-hwaddr_len.patch
+++ b/stubdom/lwip.dhcp_create_request-hwaddr_len.patch
@@ -1,26 +1,13 @@
----
- 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*/;
++    dhcp->msg_out->chaddr[i] = (i < (netif->hwaddr_len > NETIF_MAX_HWADDR_LEN ? NETIF_MAX_HWADDR_LEN : netif->hwaddr_len)) ? netif->hwaddr[i] : 0/* pad byte*/;
    }
    for (i = 0; i < DHCP_SNAME_LEN; i++) {
      dhcp->msg_out->sname[i] = 0;

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH for-xen-4.5] stubdom: another for fix for lwip compile
  2014-10-07 14:15 [PATCH for-xen-4.5] stubdom: another for fix for lwip compile Olaf Hering
@ 2014-10-07 16:18 ` Samuel Thibault
  2014-10-08 12:56   ` Ian Campbell
  0 siblings, 1 reply; 3+ messages in thread
From: Samuel Thibault @ 2014-10-07 16:18 UTC (permalink / raw)
  To: Olaf Hering; +Cc: Stefano Stabellini, xen-devel

Olaf Hering, le Tue 07 Oct 2014 16:15:46 +0200, a écrit :
> stubdom/lwip-x86_64/src/core/dhcp.c: In function 'dhcp_create_request':
> stubdom/lwip-x86_64/src/core/dhcp.c:1361:64: error: array subscript is above array bounds
> 
> The previous attempt to fix the failure above worked fine in SLE11,
> openSUSE 13.1 and newer. But gcc-4.5 as included in openSUSE 11.4 still
> failed to compile. To fix compilation also with this version of gcc move
> the range check right into the code instead of assigning it to a
> temporary variable.
> 
> Signed-off-by: Olaf Hering <olaf@aepfle.de>
> Cc: Samuel Thibault <samuel.thibault@ens-lyon.org>
> Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>

Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

> ---
>  stubdom/lwip.dhcp_create_request-hwaddr_len.patch | 15 +--------------
>  1 file changed, 1 insertion(+), 14 deletions(-)
> 
> diff --git a/stubdom/lwip.dhcp_create_request-hwaddr_len.patch b/stubdom/lwip.dhcp_create_request-hwaddr_len.patch
> index 12f1014..c43f282 100644
> --- a/stubdom/lwip.dhcp_create_request-hwaddr_len.patch
> +++ b/stubdom/lwip.dhcp_create_request-hwaddr_len.patch
> @@ -1,26 +1,13 @@
> ----
> - 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*/;
> ++    dhcp->msg_out->chaddr[i] = (i < (netif->hwaddr_len > NETIF_MAX_HWADDR_LEN ? NETIF_MAX_HWADDR_LEN : netif->hwaddr_len)) ? netif->hwaddr[i] : 0/* pad byte*/;
>     }
>     for (i = 0; i < DHCP_SNAME_LEN; i++) {
>       dhcp->msg_out->sname[i] = 0;
> 

-- 
Samuel
Running Windows on a Pentium is like having a brand new Porsche but only
be able to drive backwards with the handbrake on.
(Unknown source)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH for-xen-4.5] stubdom: another for fix for lwip compile
  2014-10-07 16:18 ` Samuel Thibault
@ 2014-10-08 12:56   ` Ian Campbell
  0 siblings, 0 replies; 3+ messages in thread
From: Ian Campbell @ 2014-10-08 12:56 UTC (permalink / raw)
  To: Samuel Thibault; +Cc: Olaf Hering, xen-devel, Stefano Stabellini

On Tue, 2014-10-07 at 18:18 +0200, Samuel Thibault wrote:
> Olaf Hering, le Tue 07 Oct 2014 16:15:46 +0200, a écrit :
> > stubdom/lwip-x86_64/src/core/dhcp.c: In function 'dhcp_create_request':
> > stubdom/lwip-x86_64/src/core/dhcp.c:1361:64: error: array subscript is above array bounds
> > 
> > The previous attempt to fix the failure above worked fine in SLE11,
> > openSUSE 13.1 and newer. But gcc-4.5 as included in openSUSE 11.4 still
> > failed to compile. To fix compilation also with this version of gcc move
> > the range check right into the code instead of assigning it to a
> > temporary variable.
> > 
> > Signed-off-by: Olaf Hering <olaf@aepfle.de>
> > Cc: Samuel Thibault <samuel.thibault@ens-lyon.org>
> > Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> 
> Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

applied.



_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-10-08 12:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-07 14:15 [PATCH for-xen-4.5] stubdom: another for fix for lwip compile Olaf Hering
2014-10-07 16:18 ` Samuel Thibault
2014-10-08 12:56   ` Ian Campbell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.