EGPRS: fix for EPDAN out of window

Fix alignment of EPDAN outside the RLC transmit window,
according to section 9.1.8.2.4 in 44.060 version 7.27.0 Release 7.
The specification explains that a bit within the uncompressed bitmap
whose corresponding BSN is not within the transmit window shall be
ignored. Without this fix PCU was dropping the EPDAN message and not
updating the status of BSNs which are inside the RLC window. This patch
updates the status of the BSNs which are inside the window and ignores
the remaining bits.

Related: OS#1789

Change-Id: Id07d178970f168f5389016c1eea31eb6b82057b6
diff --git a/src/rlc.cpp b/src/rlc.cpp
index ee2635a..2bffccb 100644
--- a/src/rlc.cpp
+++ b/src/rlc.cpp
@@ -105,7 +105,9 @@
 			uint16_t first_bsn, uint16_t *lost,
 			uint16_t *received)
 {
-	unsigned num_blocks = rbb->cur_bit;
+	unsigned dist = distance();
+	unsigned num_blocks = rbb->cur_bit > dist
+				? dist : rbb->cur_bit;
 	unsigned bsn;
 
 	/* first_bsn is in range V(A)..V(S) */