Просмотр исходного кода

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 лет назад
Родитель
Сommit
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)
 		}