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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Mon, 22 Jan 2024 15:12:04 -0800
From: Greg KH <gregkh@...uxfoundation.org>
To: Danilo Krummrich <dakr@...hat.com>
Cc: ojeda@...nel.org, alex.gaynor@...il.com, wedsonaf@...il.com,
	boqun.feng@...il.com, gary@...yguo.net, bjorn3_gh@...tonmail.com,
	benno.lossin@...ton.me, a.hindborg@...sung.com,
	aliceryhl@...gle.com, rust-for-linux@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] rust: str: add to_ascii_{upper,lower}case() to CString

On Mon, Jan 22, 2024 at 11:38:34PM +0100, Danilo Krummrich wrote:
> On Mon, Jan 22, 2024 at 11:35:29AM -0800, Greg KH wrote:
> > On Mon, Jan 22, 2024 at 07:45:57PM +0100, Danilo Krummrich wrote:
> > > Add functions to convert a CString to upper- / lowercase assuming all
> > > characters are ASCII encoded.
> > > 
> > > Signed-off-by: Danilo Krummrich <dakr@...hat.com>
> > > ---
> > >  rust/kernel/str.rs | 10 ++++++++++
> > >  1 file changed, 10 insertions(+)
> > > 
> > > diff --git a/rust/kernel/str.rs b/rust/kernel/str.rs
> > > index 7d848b83add4..d21151d89861 100644
> > > --- a/rust/kernel/str.rs
> > > +++ b/rust/kernel/str.rs
> > > @@ -581,6 +581,16 @@ pub fn try_from_fmt(args: fmt::Arguments<'_>) -> Result<Self, Error> {
> > >          // exist in the buffer.
> > >          Ok(Self { buf })
> > >      }
> > > +
> > > +    /// Converts the whole CString to lowercase.
> > > +    pub fn to_ascii_lowercase(&mut self) {
> > > +        self.buf.make_ascii_lowercase();
> > > +    }
> > > +
> > > +    /// Converts the whole CString to uppercase.
> > > +    pub fn to_ascii_uppercase(&mut self) {
> > > +        self.buf.make_ascii_uppercase();
> > > +    }
> > 
> > How are you handling locales?
> 
> For ASCII only? Not at all, I guess.

Ah, this is ascii, yes, sorry.  So this is a replacement of
toupper()/tolower() in the C api?

> However, std::slice::make_ascii_{lower,upper]case() doesn't seem to handle the
> extended range, which tolower() / toupper(), according to _ctype[], does. Do
> you mean that?

You should support whatever those functions in the kernel support today,
otherwise why add it?  And why not just call the kernel function to be
sure?

thanks,

greg k-h

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ