[PATCH] ipcpd: Fix bounds check on PROG_MAX_FLOWS

  • From: Dimitri Staessens <dimitri@ouroboros.rocks>
  • To: ouroboros@xxxxxxxxxxxxx
  • Date: Thu, 17 Feb 2022 18:22:05 +0100

Off-by-one error in the bounds check.

Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks>
---
 src/ipcpd/unicast/fa.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/ipcpd/unicast/fa.c b/src/ipcpd/unicast/fa.c
index 5edf77aa..ef6adae6 100644
--- a/src/ipcpd/unicast/fa.c
+++ b/src/ipcpd/unicast/fa.c
@@ -143,7 +143,7 @@ static int fa_rib_read(const char * path,
 
         fd = atoi(entry);
 
-        if (fd < 0 || fd > PROG_MAX_FLOWS)
+        if (fd < 0 || fd >= PROG_MAX_FLOWS)
                 return -1;
 
         if (len < 1536)
@@ -303,7 +303,7 @@ static int eid_to_fd(uint64_t eid)
 
         fd = eid & 0xFFFFFFFF;
 
-        if (fd < 0 || fd > PROG_MAX_FLOWS)
+        if (fd < 0 || fd >= PROG_MAX_FLOWS)
                 return -1;
 
         flow = &fa.flows[fd];
-- 
2.35.1


Other related posts:

  • » [PATCH] ipcpd: Fix bounds check on PROG_MAX_FLOWS - Dimitri Staessens