[patch] netstat: got bogus unix line...

Cristian Ionescu-Idbohrn cristian.ionescu-idbohrn at axis.com
Wed Jan 2 08:45:47 PST 2008


On Wed, 2 Jan 2008, Denys Vlasenko wrote:

> The thread started by you reporting a bug where netstat crashed trying
> to print binary data to stdout. This was fixed.

Yes, and I'm happy with that fix.

> Now it even prints non-printable characters safely.

And that's very good too.

> The only remaining problems are that it does not print weird names with
> embedded NULs, and does not like even weirder names with '\n' in them.

Those are IMO not problems.  bb-netstat should _not_ print weird names
with embedded NULs or even weirder names with '\n' in them.

> In the first case netstat just prints everything up to NUL (with no
> warning),

Right.

> in second case it will warn about "bogus line".

That does not happen in my case.  bb-netstat does not print any "bogus
line" warning when the line read from /proc/net/unix looks like this:

00000350:                     6637 6162 3632 3830          f7ab6280
00000360: 3A20 3030 3030 3030 3032 2030 3030 3030  : 00000002 00000
00000370: 3030 3020 3030 3030 3030 3030 2030 3030  000 00000000 000
00000380: 3220 3031 2031 3439 3534 2040 0000 009E  2 01 14954 @....
00000390: 1200 0078 2A0A 0000 0000 0000 0000 0000  ...x*...........
000003A0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
000003B0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
000003C0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
000003D0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
000003E0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
000003F0: 0000 0000 0000 000A                      ........

Two embedded '\n' above.

net-tools netstat warns, but I'm not sure if the warning adresses the 1st
part (up to the 1st '\n') or the 2nd part which starts with NUL characters
and ends with a '\n'.

> You want first case to also emit a warning. You add code to detect it.

Yes, because that indicates corruption.

> I don't agree on that, since does not seem to be particularly useful,
> even worse: it will warn on this name:
>
> @/tmp/fam-vda-^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@...^@
>
> which looks like a non-bogus name to me.

Hmm...  Looks bogus to me.

> I think current netstat behavior is good enough.

Alright.  I won't push it any further.  I think we can agree that we
disagree on that matter ;)


Cheers,

-- 
Cristian


More information about the busybox mailing list