]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
ss: Fix accidental state filter override
authorPhil Sutter <phil@nwl.cc>
Wed, 13 Apr 2016 20:07:05 +0000 (22:07 +0200)
committerStephen Hemminger <stephen@networkplumber.org>
Tue, 19 Apr 2016 14:56:53 +0000 (07:56 -0700)
Passing a filter expression and selecting an address family using the
'-f' flag would overwrite the state filter by accident. Therefore
calling e.g. 'ss -nl -f inet '(sport = :22)' would not only print
listening sockets (as requested by '-l' flag) but connected ones, as
well.

Fix this by reusing the formerly ineffective call to filter_states_set()
to restore the state filter as it was before the call to
filter_af_set().

Signed-off-by: Phil Sutter <phil@nwl.cc>
misc/ss.c

index d6090018c5dbbf16058dca19ed17627984d54072..544def3f08ea8241a308572f43f3581823debafc 100644 (file)
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -1556,9 +1556,10 @@ void *parse_hostcond(char *addr, bool is_port)
 
 out:
        if (fam != AF_UNSPEC) {
+               int states = f->states;
                f->families = 0;
                filter_af_set(f, fam);
-               filter_states_set(f, 0);
+               filter_states_set(f, states);
        }
 
        res = malloc(sizeof(*res));