Browse Source

issue #7 - read payload for all FLAP types

When reading the FLAP frame, we previously read the payload for data
frames only and ignored the payload for other frame types. This would
cause alignment issues when the FLAP reader did not consume the payload,
causing the next FLAP to be read at the wrong byte offset.

With this fix, we read the FLAP payload for all FLAP types.
Mike 2 years ago
parent
commit
e607b7311e
1 changed files with 4 additions and 6 deletions
  1. 4 6
      server/oscar/connection.go

+ 4 - 6
server/oscar/connection.go

@@ -145,13 +145,11 @@ func consumeFLAPFrames(r io.Reader, msgCh chan incomingMessage, errCh chan error
 			return
 			return
 		}
 		}
 
 
-		if in.flap.FrameType == wire.FLAPFrameData {
+		if in.flap.PayloadLength > 0 {
 			buf := make([]byte, in.flap.PayloadLength)
 			buf := make([]byte, in.flap.PayloadLength)
-			if in.flap.PayloadLength > 0 {
-				if _, err := io.ReadFull(r, buf); err != nil {
-					errCh <- err
-					return
-				}
+			if _, err := io.ReadFull(r, buf); err != nil {
+				errCh <- err
+				return
 			}
 			}
 			in.payload = bytes.NewBuffer(buf)
 			in.payload = bytes.NewBuffer(buf)
 		}
 		}