[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20191120.222348.90358085054106479.davem@davemloft.net>
Date: Wed, 20 Nov 2019 22:23:48 -0800 (PST)
From: David Miller <davem@...emloft.net>
To: liuhangbin@...il.com
Cc: netdev@...r.kernel.org, jbenc@...hat.com, eric.dumazet@...il.com
Subject: Re: [PATCHv2 net-next] tcp: warn if offset reach the maxlen limit
when using snprintf
From: Hangbin Liu <liuhangbin@...il.com>
Date: Wed, 20 Nov 2019 16:38:08 +0800
> snprintf returns the number of chars that would be written, not number
> of chars that were actually written. As such, 'offs' may get larger than
> 'tbl.maxlen', causing the 'tbl.maxlen - offs' being < 0, and since the
> parameter is size_t, it would overflow.
>
> Since using scnprintf may hide the limit error, while the buffer is still
> enough now, let's just add a WARN_ON_ONCE in case it reach the limit
> in future.
>
> v2: Use WARN_ON_ONCE as Jiri and Eric suggested.
>
> Suggested-by: Jiri Benc <jbenc@...hat.com>
> Signed-off-by: Hangbin Liu <liuhangbin@...il.com>
Applied.
Powered by blists - more mailing lists