buglwIP - A Lightweight TCP/IP stack - Bugs: bug #18924, index in etharp.c ( function...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

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

Submitter:  None
Submitted:  Thu 01 Feb 2007 04:37:00 AM UTC
   
 
Category:  pbufs Severity:  3 - Normal
Item Group:  None Status:  Invalid
Privacy:  Public Assigned to:  None
Open/Closed:  Closed Planned Release:  None
lwIP version:  None

Thu 01 Feb 2007 05:48:43 AM UTC, comment #3: 

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

Anonymous
Thu 01 Feb 2007 05:10:27 AM UTC, comment #2: 

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].

David Empson <dempson>
Thu 01 Feb 2007 04:40:48 AM UTC, comment #1: 

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

Anonymous
Thu 01 Feb 2007 04:37:00 AM UTC, original submission:  

      //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.

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by kieranm (Updated the item)
  • -email is unavailable- added by dempson (Posted a comment)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2007-02-06 kieranm StatusNone Invalid
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code