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 )

Submitted by:  None
Submitted on:  Thu 01 Feb 2007 04:37:00 AM UTC  
 
Category: pbufsSeverity: 3 - Normal
Item Group: NoneStatus: Invalid
Privacy: PublicAssigned to: None
Open/Closed: ClosedPlanned 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

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 06 Feb 2007 10:55:27 AM UTCkieranmStatusNone=>Invalid
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1