[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20170821173404.585ff766@xeon-e3>
Date: Mon, 21 Aug 2017 17:34:04 -0700
From: Stephen Hemminger <stephen@...workplumber.org>
To: Phil Sutter <phil@....cc>
Cc: netdev@...r.kernel.org
Subject: Re: [iproute PATCH v2 2/7] ss: Make sure index variable is >= 0
On Mon, 21 Aug 2017 19:08:08 +0200
Phil Sutter <phil@....cc> wrote:
> This shouldn't happen but relying upon external data without checking
> may lead to unexpected results.
>
> Signed-off-by: Phil Sutter <phil@....cc>
> ---
> misc/ss.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/misc/ss.c b/misc/ss.c
> index 10360e5a04ff8..1ee02d73b2d7f 100644
> --- a/misc/ss.c
> +++ b/misc/ss.c
> @@ -2004,7 +2004,7 @@ static void tcp_timer_print(struct tcpstat *s)
> "unknown"
> };
>
> - if (s->timer) {
> + if (s->timer >= 0) {
> if (s->timer > 4)
> s->timer = 5;
> printf(" timer:(%s,%s,%d)",
Let's go one step deeper on this.
Why is s->timer an int, it should be unsigned. In which case the code in
print would not have to change.
Powered by blists - more mailing lists