[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <989d091b100a4dfcbce0dce81b48e672@AcuMS.aculab.com>
Date: Thu, 23 Mar 2023 22:23:11 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Kees Cook' <keescook@...omium.org>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
CC: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Cezary Rojewski <cezary.rojewski@...el.com>,
"linux-ext4@...r.kernel.org" <linux-ext4@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Theodore Ts'o <tytso@....edu>, Jan Kara <jack@...e.com>,
Andy Shevchenko <andy@...nel.org>,
"Rafael J. Wysocki" <rafael@...nel.org>
Subject: RE: [PATCH v1 2/3] lib/string_helpers: Change returned value of the
strreplace()
From: Kees Cook
> Sent: 22 March 2023 16:51
>
> On Wed, Mar 22, 2023 at 04:12:05PM +0200, Andy Shevchenko wrote:
> > It's more useful to return the original string with strreplace(),
Won't that break anything that is using the result?
> I found the use of "original" confusing here and in the comments. This
> just returns arg 1, yes? i.e. it's not the original (unreplaced) string,
> but rather just the string itself.
>
> I agree, though, that's much more useful than a pointer to the end of
> the string.
If you want a pointer to the start of the string, you've
already got it.
Almost all the time you can do the assignment first.
But if you want a pointer to the end you'll need to scan it again.
I have a feeling that the reason many of the string functions
return the original pointer is a historic side effect of
the original implementation.
Going back to before C had a 'return' statement.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Powered by blists - more mailing lists