[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <557b2545-3b3c-63a9-580c-270a0a103b2e@gmail.com>
Date: Thu, 14 Nov 2019 06:28:35 -0800
From: Eric Dumazet <eric.dumazet@...il.com>
To: Hangbin Liu <liuhangbin@...il.com>, netdev@...r.kernel.org
Cc: Eric Dumazet <edumazet@...gle.com>,
"David S . Miller" <davem@...emloft.net>,
Jiri Benc <jbenc@...hat.com>
Subject: Re: [PATCH net] tcp: switch snprintf to scnprintf
On 11/14/19 2:28 AM, Hangbin Liu wrote:
> 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.
>
> Currently, the buffer is still enough, but for future design, use scnprintf
> would be safer.
>
Why is it targeting net tree ?
How have you checked that it was actually safer ?
This looks unnecessary code churn to me, and it might hide an error in the future.
We need to properly size the output buffers before using them,
we can not afford truncating silently the output.
Powered by blists - more mailing lists