Skip to contentSkip to conversation

ss: Fix socket type check in packet_show_line()

PATCH New Phil Sutter 1 participant 1 message Aug 22, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ss: Fix socket type check in packet_show_line()

The field is accessed before being assigned a meaningful value, effectively disabling the checks.

Fixes 4a0053b606a34 ("ss: Unify packet stats output from netlink and proc")
---
 misc/ss.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
misc/ss.c +2 -2
index de54b0da7a192..5156faf4dca7f 100644
@@ -4534,9 +4534,9 @@ static int packet_show_line(char *buf, const struct filter *f, int fam)
 			&type, &prot, &iface, &state,
 			&rq, &uid, &ino);
 
-	if (stat.type == SOCK_RAW && !(f->dbs&(1<<PACKET_R_DB)))
+	if (type == SOCK_RAW && !(f->dbs&(1<<PACKET_R_DB)))
 		return 0;
-	if (stat.type == SOCK_DGRAM && !(f->dbs&(1<<PACKET_DG_DB)))
+	if (type == SOCK_DGRAM && !(f->dbs&(1<<PACKET_DG_DB)))
 		return 0;
 
 	stat.type  = type;
Signature · 1 line
2.41.0