]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
ss: Make sure scanned index value to unix_state_map is sane
authorPhil Sutter <phil@nwl.cc>
Thu, 24 Aug 2017 09:41:27 +0000 (11:41 +0200)
committerStephen Hemminger <stephen@networkplumber.org>
Thu, 24 Aug 2017 22:22:10 +0000 (15:22 -0700)
Signed-off-by: Phil Sutter <phil@nwl.cc>
misc/ss.c

index be498ebe3ba5c70f1ee1057c1f1508b9ca8eb13c..fcc3cf9282c49ef761894ce68e75a4773ae4a968 100644 (file)
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -3148,7 +3148,8 @@ static int unix_show(struct filter *f)
 
                if (flags & (1 << 16)) {
                        u->state = SS_LISTEN;
-               } else {
+               } else if (u->state > 0 &&
+                          u->state <= ARRAY_SIZE(unix_state_map)) {
                        u->state = unix_state_map[u->state-1];
                        if (u->type == SOCK_DGRAM && u->state == SS_CLOSE && u->rport)
                                u->state = SS_ESTABLISHED;