|
Message-ID: <396d1eed-8edf-aa77-110b-c50ead3a5fd5@rasmusvillemoes.dk> Date: Wed, 24 Jul 2019 15:09:10 +0200 From: Rasmus Villemoes <linux@...musvillemoes.dk> To: Yann Droneaud <ydroneaud@...eya.com>, David Laight <David.Laight@...LAB.COM>, Joe Perches <joe@...ches.com>, Linus Torvalds <torvalds@...ux-foundation.org>, "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org> Cc: Jonathan Corbet <corbet@....net>, Stephen Kitt <steve@....org>, Kees Cook <keescook@...omium.org>, Nitin Gote <nitin.r.gote@...el.com>, "jannh@...gle.com" <jannh@...gle.com>, "kernel-hardening@...ts.openwall.com" <kernel-hardening@...ts.openwall.com>, Andrew Morton <akpm@...ux-foundation.org> 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. Rasmus
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.