[PATCH] lib: Fix bad bounds calculation in frct

  • From: Dimitri Staessens <dimitri.staessens@xxxxxxxx>
  • To: ouroboros@xxxxxxxxxxxxx
  • Date: Fri, 8 Jun 2018 11:08:15 +0200

Since the seqno is further ahead than the lwe (this was checked
before), we can safely use seqno - lwe in unsigned arithmetic as the
distance in the sequence number space.

Signed-off-by: Dimitri Staessens <dimitri.staessens@xxxxxxxx>
---
 src/lib/frct.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/lib/frct.c b/src/lib/frct.c
index 0026127..296d5b2 100644
--- a/src/lib/frct.c
+++ b/src/lib/frct.c
@@ -385,7 +385,7 @@ static int __frcti_rcv(struct frcti *       frcti,
 
                 if (rcv_cr->cflags & FRCTFRTX) {
                         size_t pos = seqno & (RQ_SIZE - 1);
-                        if ((seqno - RQ_SIZE - rcv_cr->lwe) > 0 /* Out of rq. 
*/
+                        if ((seqno - rcv_cr->lwe) > RQ_SIZE /* Out of rq. */
                             || frcti->rq[pos] != -1) /* Duplicate in rq. */
                                 goto drop_packet;
                         /* Queue. */
-- 
2.17.1


Other related posts:

  • » [PATCH] lib: Fix bad bounds calculation in frct - Dimitri Staessens