patchlwIP - A Lightweight TCP/IP stack - Patches: patch #7264, protocols are rejected incorrectly...

 
 

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

patch #7264: protocols are rejected incorrectly on big endian architectures

Submitter:  Greg Renda <greg>
Submitted:  Fri 30 Jul 2010 11:27:02 PM UTC
   
 
Category:  None Priority:  5 - Normal
Status:  Done Privacy:  Public
Assigned to:  goldsimon Open/Closed:  Closed
Planned Release:  None

Sun 01 Aug 2010 11:15:51 AM UTC, comment #3: 

Ah, well, I just discovered my mistake: I thought that the protocol was to be copied to the same memory where it is read from at the top of the function, however, that's not the case as the struct has a padding of 2 on platforms where 'int' is 4 bytes and which need 4-byte alignment.

So we either would need to pack the struct pppInputHeader to make the code work like the original author meant it to work or just apply your patch, which is what I jsut did.

Thanks for reporting.

Simon Goldschmidt <goldsimon>
Group administrator
Sat 31 Jul 2010 03:44:52 PM UTC, comment #2: 

Yes, I actually observed this bug.  The reason the value is no longer there is this line near the top of the function:

if(pbuf_header(nb, -(int)sizeof(struct pppInputHeader))) {

which increments nb->payload by sizeof(struct pppInputHeader).

Greg Renda <greg>
Sat 31 Jul 2010 06:18:33 AM UTC, comment #1: 

Did you really observe that bug or did you report it from reading the code? Because from my reading the code, the value should still be there (at nb->payload): nb is untouched in case default unless we find a matching protocol, but in that case, the code you want to be changed is not reached.

However, I don't know right now why the protocol value seems to come in as host-order and is sent out in network-order, but that's a different issue...

Simon Goldschmidt <goldsimon>
Group administrator
Fri 30 Jul 2010 11:27:02 PM UTC, original submission:  

An unrecognized protocol isn't rejected properly when BYTE_ORDER != LITTLE_ENDIAN.  The protocol id isn't copied into the output buffer.

--- ppp.c.orig  2010-07-30 16:24:12.000000000 -0700
+++ ppp.c       2010-07-30 16:24:28.000000000 -0700
@@ -1704,8 +1704,8 @@
       }
 #if BYTE_ORDER == LITTLE_ENDIAN
       protocol = htons(protocol);
-      SMEMCPY(nb->payload, &protocol, sizeof(protocol));
 #endif /* BYTE_ORDER == LITTLE_ENDIAN */
+      SMEMCPY(nb->payload, &protocol, sizeof(protocol));
       lcp_sprotrej(pd, nb->payload, nb->len);
     }
     break;

Greg Renda <greg>

 

(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 goldsimon (Posted a comment)
  • -email is unavailable- added by greg (Submitted the item)
  •  

    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 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2010-08-01 goldsimon StatusNeed Info Done
        Assigned toNone goldsimon
        Open/ClosedOpen Closed
    2010-07-31 goldsimon StatusNone Need Info

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code