Skip to contentSkip to conversation

unix: escape all null bytes in abstract unix domain socket

PATCH Applied Isaac Boukris 2 participants 2 messages Nov 1, 2016

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

PATCH v2 1/1 unix: escape all null bytes in abstract unix domain socket

Abstract unix domain socket may embed null characters, these should be translated to '@' when printed out to proc the same way the null prefix is currently being translated.

This helps for tools such as netstat, lsof and the proc based implementation in ss to show all the significant bytes of the name (instead of getting cut at the first null occurrence).

---
 net/unix/af_unix.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/unix/af_unix.c +2 -1
index 145082e..5d1c14a 100644
@@ -2812,7 +2812,8 @@ static int unix_seq_show(struct seq_file *seq, void *v)
 				i++;
 			}
 			for ( ; i < len; i++)
-				seq_putc(seq, u->addr->name->sun_path[i]);
+				seq_putc(seq, u->addr->name->sun_path[i] ?:
+					 '@');
 		}
 		unix_state_unlock(s);
 		seq_putc(seq, '\n');
Signature · 1 line
2.7.4
maintainer Applied
#1 lore raw

From: Isaac Boukris <[email protected]>
Date: Tue, 1 Nov 2016 02:41:35 +0200

Quoted 11 lines

Abstract unix domain socket may embed null characters, these should be translated to '@' when printed out to proc the same way the null prefix is currently being translated.

This helps for tools such as netstat, lsof and the proc based implementation in ss to show all the significant bytes of the name (instead of getting cut at the first null occurrence).

Applied, thank you.