all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Maximiliano Sandoval <m.sandoval@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox 2/2] sys: crypt: use is_some_and
Date: Tue, 27 Aug 2024 09:56:27 +0200	[thread overview]
Message-ID: <20240827075627.79819-2-m.sandoval@proxmox.com> (raw)
In-Reply-To: <20240827075627.79819-1-m.sandoval@proxmox.com>

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 proxmox-sys/src/crypt.rs | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/proxmox-sys/src/crypt.rs b/proxmox-sys/src/crypt.rs
index 5565d0d5..5d8826a9 100644
--- a/proxmox-sys/src/crypt.rs
+++ b/proxmox-sys/src/crypt.rs
@@ -71,7 +71,12 @@ pub fn crypt(password: &[u8], salt: &[u8]) -> Result<String, Error> {
         // > output field of their data argument, and crypt writes an invalid hash to its static
         // > storage area.  This string will be shorter than 13 characters, will begin with a ‘*’,
         // > and will not compare equal to setting.
-        if data.output.first().is_none() || Some(&('*' as libc::c_char)) == data.output.first() {
+        if data.output.first().is_none()
+            || data
+                .output
+                .first()
+                .is_some_and(|c| *c == '*' as libc::c_char)
+        {
             bail!("internal error: crypt_r returned invalid hash");
         }
         CStr::from_ptr(&data.output as *const _)
@@ -133,7 +138,7 @@ pub fn crypt_gensalt(prefix: &str, count: u64, rbytes: &[u8]) -> Result<String,
     // while it states that this is "in addition" to returning a null pointer, this isn't how
     // `crypt_r` seems to behave (sometimes only setting an invalid hash) so add this here too just
     // in case.
-    if output.first().is_none() || Some(&('*' as libc::c_char)) == output.first() {
+    if output.first().is_none() || output.first().is_some_and(|c| *c == '*' as libc::c_char) {
         bail!("internal error: crypt_gensalt_rn could not create a valid salt");
     }
 
-- 
2.39.2



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel

  reply	other threads:[~2024-08-27  7:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-27  7:56 [pbs-devel] [PATCH proxmox 1/2] sys: crypt: use c_char for crypt ffi Maximiliano Sandoval
2024-08-27  7:56 ` Maximiliano Sandoval [this message]
2024-08-28 11:08 ` [pbs-devel] nak: " Wolfgang Bumiller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240827075627.79819-2-m.sandoval@proxmox.com \
    --to=m.sandoval@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal