Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5ece6c2d authored by Alexey Dobriyan's avatar Alexey Dobriyan Committed by David S. Miller
Browse files

net: fix tiny output corruption of /proc/net/snmp6



Because "name" is static, it can be occasionally be filled with
somewhat garbage if two processes read /proc/net/snmp6.

Also, remove useless casts and "-1" -- snprintf() correctly terminates it's
output.

Signed-off-by: default avatarAlexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a849854f
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -132,7 +132,7 @@ static struct snmp_mib snmp6_udplite6_list[] = {


static void snmp6_seq_show_icmpv6msg(struct seq_file *seq, void **mib)
static void snmp6_seq_show_icmpv6msg(struct seq_file *seq, void **mib)
{
{
	static char name[32];
	char name[32];
	int i;
	int i;


	/* print by name -- deprecated items */
	/* print by name -- deprecated items */
@@ -144,7 +144,7 @@ static void snmp6_seq_show_icmpv6msg(struct seq_file *seq, void **mib)
		p = icmp6type2name[icmptype];
		p = icmp6type2name[icmptype];
		if (!p)	/* don't print un-named types here */
		if (!p)	/* don't print un-named types here */
			continue;
			continue;
		(void) snprintf(name, sizeof(name)-1, "Icmp6%s%s",
		snprintf(name, sizeof(name), "Icmp6%s%s",
			i & 0x100 ? "Out" : "In", p);
			i & 0x100 ? "Out" : "In", p);
		seq_printf(seq, "%-32s\t%lu\n", name,
		seq_printf(seq, "%-32s\t%lu\n", name,
			snmp_fold_field(mib, i));
			snmp_fold_field(mib, i));
@@ -157,7 +157,7 @@ static void snmp6_seq_show_icmpv6msg(struct seq_file *seq, void **mib)
		val = snmp_fold_field(mib, i);
		val = snmp_fold_field(mib, i);
		if (!val)
		if (!val)
			continue;
			continue;
		(void) snprintf(name, sizeof(name)-1, "Icmp6%sType%u",
		snprintf(name, sizeof(name), "Icmp6%sType%u",
			i & 0x100 ?  "Out" : "In", i & 0xff);
			i & 0x100 ?  "Out" : "In", i & 0xff);
		seq_printf(seq, "%-32s\t%lu\n", name, val);
		seq_printf(seq, "%-32s\t%lu\n", name, val);
	}
	}