Преглед на файлове

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 години
родител
ревизия
e607b7311e
променени са 1 файла, в които са добавени 4 реда и са изтрити 6 реда
  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
 		}
 
-		if in.flap.FrameType == wire.FLAPFrameData {
+		if in.flap.PayloadLength > 0 {
 			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)
 		}