lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aQ29Zzajef81E2DZ@smile.fi.intel.com>
Date: Fri, 7 Nov 2025 11:35:35 +0200
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: David Laight <david.laight.linux@...il.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
	Junrui Luo <moonafterrain@...look.com>,
	linux-kernel@...r.kernel.org, pmladek@...e.com, rostedt@...dmis.org,
	tiwai@...e.com, perex@...ex.cz, linux-sound@...r.kernel.org,
	mchehab@...nel.org, awalls@...metrocast.net,
	linux-media@...r.kernel.org, davem@...emloft.net,
	edumazet@...gle.com, kuba@...nel.org, pabeni@...hat.com,
	netdev@...r.kernel.org
Subject: Re: [PATCH 1/4] lib/sprintf: add scnprintf_append() helper function

On Fri, Nov 07, 2025 at 09:12:46AM +0000, David Laight wrote:
> On Thu, 6 Nov 2025 21:38:33 -0800
> Andrew Morton <akpm@...ux-foundation.org> wrote:
> > On Fri,  7 Nov 2025 13:16:13 +0800 Junrui Luo <moonafterrain@...look.com> wrote:

...

> That is true for all the snprintf() functions.
> 
> > I wonder if we should instead implement a kasprintf() version of this
> > which reallocs each time and then switch all the callers over to that.
> 
> That adds the cost of a malloc, and I, like kasprintf() probably ends up
> doing all the work of snprintf twice.
> 
> I'd be tempted to avoid the strlen() by passing in the offset.
> So (say):
> #define scnprintf_at(buf, len, off, ...) \
> 	scnprintf((buf) + off, (len) - off, __VA_ARGS__)
> 
> Then you can chain calls, eg:
> 	off = scnprintf(buf, sizeof buf, ....);
> 	off += scnprintf_at(buf, sizeof buf, off, ....);

I like this suggestion. Also note, that the original implementation works directly
on static buffers.

-- 
With Best Regards,
Andy Shevchenko



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ