Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Wed, 24 Jul 2019 15:09:10 +0200
From: Rasmus Villemoes <>
To: Yann Droneaud <>,
 David Laight <David.Laight@...LAB.COM>, Joe Perches <>,
 Linus Torvalds <>,
 "" <>
Cc: Jonathan Corbet <>, Stephen Kitt <>,
 Kees Cook <>, Nitin Gote <>,
 "" <>,
 "" <>,
 Andrew Morton <>
Subject: Re: [PATCH 1/2] string: Add stracpy and stracpy_pad mechanisms

On 24/07/2019 14.05, Yann Droneaud wrote:
> Hi,

> Beware that snprintf(), per C standard, is supposed to return the
> length of the formatted string, regarless of the size of the
> destination buffer.
> So encouraging developper to write something like code below because
> snprintf() in kernel behave in a non-standard way,

The kernel's snprintf() does not behave in a non-standard way, at least
not with respect to its return value. It doesn't support %n or floating
point, of course, and there are some quirks regarding precision (see
lib/test_printf.c for details).

There's the non-standard scnprintf() for getting the length of the
formatted string, which can safely be used in an append loop. Or one can
use the seq_buf API.


Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.