public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox 1/2] sys: crypt: use c_char for crypt ffi
@ 2024-08-27  7:56 Maximiliano Sandoval
  2024-08-27  7:56 ` [pbs-devel] [PATCH proxmox 2/2] sys: crypt: use is_some_and Maximiliano Sandoval
  2024-08-28 11:08 ` [pbs-devel] nak: [PATCH proxmox 1/2] sys: crypt: use c_char for crypt ffi Wolfgang Bumiller
  0 siblings, 2 replies; 3+ messages in thread
From: Maximiliano Sandoval @ 2024-08-27  7:56 UTC (permalink / raw)
  To: pbs-devel

As per

    man 3 crypt

`crypt_r`'s `data` argument has an `output` consisting of chars.

    struct crypt_data {
        char output[CRYPT_OUTPUT_SIZE];
        char setting[CRYPT_OUTPUT_SIZE];
        char input[CRYPT_MAX_PASSPHRASE_SIZE];
        char initialized;
    };

and, from

    man 3 crypt_gensalt_rn

crypt_gensalt_rn has signature

    char *
    crypt_gensalt_rn(const char * prefix, unsigned long count, const char *rbytes, int nrbytes, char * output, int output_size);

To reflect this the one should use `libc:c_char` in both calls.

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---

This came up at [1].

[1] https://forum.proxmox.com/threads/inofficial-proxmox-backup-client-rpm-builds-for-rhel-based-distros.122862/#post-697268

 proxmox-sys/src/crypt.rs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/proxmox-sys/src/crypt.rs b/proxmox-sys/src/crypt.rs
index 8bc0d7e3..5565d0d5 100644
--- a/proxmox-sys/src/crypt.rs
+++ b/proxmox-sys/src/crypt.rs
@@ -71,7 +71,7 @@ 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 i8)) == data.output.first() {
+        if data.output.first().is_none() || Some(&('*' as libc::c_char)) == data.output.first() {
             bail!("internal error: crypt_r returned invalid hash");
         }
         CStr::from_ptr(&data.output as *const _)
@@ -133,7 +133,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 i8)) == output.first() {
+    if output.first().is_none() || Some(&('*' as libc::c_char)) == output.first() {
         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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-08-28 11:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [pbs-devel] [PATCH proxmox 2/2] sys: crypt: use is_some_and Maximiliano Sandoval
2024-08-28 11:08 ` [pbs-devel] nak: [PATCH proxmox 1/2] sys: crypt: use c_char for crypt ffi Wolfgang Bumiller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal