buglwIP - A Lightweight TCP/IP stack - Bugs: bug #51528, Bug when parsing WND_SCALE option

 
 

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

bug #51528: Bug when parsing WND_SCALE option

Submitter:  Pascal Quantin <pquantin>
Submitted:  Fri 21 Jul 2017 03:32:43 PM UTC
   
 
Category:  TCP Severity:  3 - Normal
Item Group:  Faulty Behaviour Status:  Fixed
Privacy:  Public Assigned to:  goldsimon
Open/Closed:  Closed Planned Release:  None
lwIP version:  2.0.2

Mon 24 Jul 2017 07:39:31 PM UTC, comment #1: 

Fixed, thanks for reporting!

Simon Goldschmidt <goldsimon>
Group administrator
Fri 21 Jul 2017 03:32:43 PM UTC, original submission:  

With the current source code, when parsing the WND_SCALE, the window scaling byte is only read if the current packet is a SYN one and not a retransmission:

        /* If syn was received with wnd scale option,
           activate wnd scale opt, but only if this is not a retransmission */
        if ((flags & TCP_SYN) && !(pcb->flags & TF_WND_SCALE)) {
          /* An WND_SCALE option with the right option length. */
          data = tcp_getoptbyte();

But the data byte should always be read, even in case of TCP retransmission. Otherwise tcp_optidx is not incremented and it breaks the rest of the options parsing.

The proposed patch below solves my issue:

diff --git a/src/core/tcp_in.c b/src/core/tcp_in.c
index ba879284..93a07678 100644
--- a/src/core/tcp_in.c
+++ b/src/core/tcp_in.c
@@ -1749,11 +1749,11 @@ tcp_parseopt(struct tcp_pcb *pcb)
           LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_parseopt: bad length\n"));
           return;
         }
+        data = tcp_getoptbyte();
         /* If syn was received with wnd scale option,
            activate wnd scale opt, but only if this is not a retransmission */
         if ((flags & TCP_SYN) && !(pcb->flags & TF_WND_SCALE)) {
           /* An WND_SCALE option with the right option length. */
-          data = tcp_getoptbyte();
           pcb->snd_scale = data;
           if (pcb->snd_scale > 14U) {
             pcb->snd_scale = 14U;

Pascal Quantin <pquantin>

 

(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 pquantin (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 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-07-24 goldsimon StatusNone Fixed
        Assigned toNone goldsimon
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-caa5.
    Corresponding source code