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] [day] [month] [year] [list]
Date: Fri, 16 Feb 2024 20:25:39 +0100
From: Alice Ryhl <alice@...l.io>
To: Danilo Krummrich <dakr@...hat.com>, Alice Ryhl <aliceryhl@...gle.com>
Cc: a.hindborg@...sung.com, alex.gaynor@...il.com, benno.lossin@...ton.me,
 bjorn3_gh@...tonmail.com, boqun.feng@...il.com, gary@...yguo.net,
 linux-kernel@...r.kernel.org, ojeda@...nel.org,
 rust-for-linux@...r.kernel.org, wedsonaf@...il.com
Subject: Re: [PATCH v3] rust: str: add {make,to}_{upper,lower}case() to
 CString

On 2/16/24 18:11, Danilo Krummrich wrote:
> On 2/16/24 17:53, Alice Ryhl wrote:
>>> +    /// Returns a copy of this [`CString`] where each character is 
>>> mapped to its
>>> +    /// ASCII upper case equivalent.
>>> +    ///
>>> +    /// ASCII letters 'a' to 'z' are mapped to 'A' to 'Z',
>>> +    /// but non-ASCII letters are unchanged.
>>> +    ///
>>> +    /// To uppercase the value in-place, use [`make_ascii_uppercase`].
>>> +    ///
>>> +    /// [`make_ascii_uppercase`]: str::make_ascii_uppercase
>>> +    pub fn to_ascii_uppercase(&self) -> Result<CString, AllocError> {
>>> +        let mut s = (*self).to_cstring()?;
>>> +
>>> +        s.make_ascii_uppercase();
>>> +
>>> +        return Ok(s);
>>> +    }
>>
>> Please move these to `CStr` as well.
> 
> That would result into two copies if I actually want a CString, wouldn't 
> it?
> 
> Also, what would be the use case? And even if someone wants to have a CStr
> again, couldn't we just deref the resulting CString?

To clarify, I want you to move it to the `impl CStr` block. That changes 
the type of the `self` argument. I don't want you to change the return 
type - that should still be `CString`.

Currently, if I have a `&CStr` and I want an uppercase `CString`, I 
can't do that with this method.

Alice

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ