[bug #18924] index in etharp.c ( function etharp_arp_input )

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[bug #18924] index in etharp.c ( function etharp_arp_input )

Wilfred

URL:
  <http://savannah.nongnu.org/bugs/?18924>

                 Summary: index in etharp.c  (  function etharp_arp_input )
                 Project: lwIP - A Lightweight TCP/IP stack
            Submitted by: None
            Submitted on: Thursday 02/01/2007 at 04:37 UTC
                Category: pbufs
                Severity: 3 - Normal
              Item Group: None
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any

    _______________________________________________________

Details:

      //i = netif->hwaddr_len;
      //while(i > 0) {
      //  i--;

        for(i=0;i<netif->hwaddr_len;i++) /* added */

      {                                  /* added */
        hdr->dhwaddr.addr[i] = hdr->shwaddr.addr[i];
        hdr->shwaddr.addr[i] = ethaddr->addr[i];
        hdr->ethhdr.dest.addr[i] = hdr->dhwaddr.addr[i];
        hdr->ethhdr.src.addr[i] = ethaddr->addr[i];
      }

The index should run from 0 to 5  NOT  1 to 6 ???

Original code is commented out.

Added 'for' loop.




    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?18924>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/



_______________________________________________
lwip-devel mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/lwip-devel
Reply | Threaded
Open this post in threaded view
|

[bug #18924] index in etharp.c ( function etharp_arp_input )

Wilfred

Follow-up Comment #1, bug #18924 (project lwip):

Might also work if you change i--;  to  --i;  so that the decrement  occurs
before the index is utilised.

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?18924>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/



_______________________________________________
lwip-devel mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/lwip-devel
Reply | Threaded
Open this post in threaded view
|

[bug #18924] index in etharp.c ( function etharp_arp_input )

Wilfred

Follow-up Comment #2, bug #18924 (project lwip):

There is nothing wrong with the original code. i-- as a separate statement
will result in i being decremented before it is first used as an array index.
It is identical to --i in this context. The first iteration of the loop will
therefore access array element 5, and the last iteration will access array
element 0.

i-- only differs from --i if it is used in a more complex expression where
the value of i is used immediately.

e.g. if i is currently 5 then addr[i--] would access addr[5] and decrement i
to 4, but addr[--i] would decrement i to 4 and access addr[4].

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?18924>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/



_______________________________________________
lwip-devel mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/lwip-devel
Reply | Threaded
Open this post in threaded view
|

[bug #18924] index in etharp.c ( function etharp_arp_input )

Wilfred

Follow-up Comment #3, bug #18924 (project lwip):

eeek ... that is correct. good thing I submitted this as anonymous.
:-)

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?18924>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/



_______________________________________________
lwip-devel mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/lwip-devel
Reply | Threaded
Open this post in threaded view
|

[bug #18924] index in etharp.c ( function etharp_arp_input )

Wilfred

Update of bug #18924 (project lwip):

                  Status:                    None => Invalid                
             Open/Closed:                    Open => Closed                


    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?18924>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/



_______________________________________________
lwip-devel mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/lwip-devel