---
 toys/net/netstat.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
From 3092e2ca49dcfd1ac445d168221a446d3b102c64 Mon Sep 17 00:00:00 2001
From: Elliott Hughes <e...@google.com>
Date: Tue, 8 Jun 2021 10:35:48 -0700
Subject: [PATCH] netstat.c: fix bounds checks.

---
 toys/net/netstat.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/toys/net/netstat.c b/toys/net/netstat.c
index 24a2ceed..7eed02da 100644
--- a/toys/net/netstat.c
+++ b/toys/net/netstat.c
@@ -182,8 +182,8 @@ static void show_unix_sockets(void)
     if (state==1 && flags && !(FLAG(a) || FLAG(l))) continue;
 
     if (type==10) type = 7; // move SOCK_PACKET into line
-    if (type>ARRAY_LEN(types)) type = 0;
-    if (state>ARRAY_LEN(states) || (state==1 && !flags)) state = 0;
+    if (type>=ARRAY_LEN(types)) type = 0;
+    if (state>=ARRAY_LEN(states) || (state==1 && !flags)) state = 0;
 
     if (state!=1 && FLAG(l)) continue;
 
-- 
2.32.0.rc1.229.g3e70b5a671-goog

_______________________________________________
Toybox mailing list
Toybox@lists.landley.net
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to