diff options
author | Andreas Schneider <asn@samba.org> | 2018-11-05 17:58:37 +0100 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2019-05-21 00:03:22 +0000 |
commit | 2915125661352b31a4c7b0143d9d93baafa400db (patch) | |
tree | 0e471434fd6178f69bb10ef77f9ae84d8b4635a4 /source3 | |
parent | bb273a0053870224862559463c5bf8d76d386e84 (diff) | |
download | samba-2915125661352b31a4c7b0143d9d93baafa400db.tar.gz |
s3:vfs: Use GnuTLS MD5 in vfs_fruit
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'source3')
-rw-r--r-- | source3/modules/vfs_fruit.c | 47 |
1 files changed, 35 insertions, 12 deletions
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index f54038f53d4..0ccc3c6f069 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -22,7 +22,6 @@ #include "smbd/smbd.h" #include "system/filesys.h" #include "lib/util/time.h" -#include "../lib/crypto/md5.h" #include "system/shmem.h" #include "locking/proto.h" #include "smbd/globals.h" @@ -35,6 +34,9 @@ #include "offload_token.h" #include "string_replace.h" +#include <gnutls/gnutls.h> +#include <gnutls/crypto.h> + /* * Enhanced OS X and Netatalk compatibility * ======================================== @@ -2383,10 +2385,11 @@ static AfpInfo *afpinfo_unpack(TALLOC_CTX *ctx, const void *data) **/ static SMB_INO_T fruit_inode(const SMB_STRUCT_STAT *sbuf, const char *sname) { - MD5_CTX ctx; + gnutls_hash_hd_t hash_hnd = NULL; unsigned char hash[16]; - SMB_INO_T result; + SMB_INO_T result = 0; char *upper_sname; + int rc; DBG_DEBUG("fruit_inode called for %ju/%ju [%s]\n", (uintmax_t)sbuf->st_ex_dev, @@ -2395,23 +2398,43 @@ static SMB_INO_T fruit_inode(const SMB_STRUCT_STAT *sbuf, const char *sname) upper_sname = talloc_strdup_upper(talloc_tos(), sname); SMB_ASSERT(upper_sname != NULL); - MD5Init(&ctx); - MD5Update(&ctx, (const unsigned char *)&(sbuf->st_ex_dev), - sizeof(sbuf->st_ex_dev)); - MD5Update(&ctx, (const unsigned char *)&(sbuf->st_ex_ino), - sizeof(sbuf->st_ex_ino)); - MD5Update(&ctx, (unsigned char *)upper_sname, - talloc_get_size(upper_sname)-1); - MD5Final(hash, &ctx); + rc = gnutls_hash_init(&hash_hnd, GNUTLS_DIG_MD5); + if (rc < 0) { + goto out; + } - TALLOC_FREE(upper_sname); + rc = gnutls_hash(hash_hnd, &(sbuf->st_ex_dev), sizeof(sbuf->st_ex_dev)); + if (rc < 0) { + gnutls_hash_deinit(hash_hnd, NULL); + goto out; + } + rc = gnutls_hash(hash_hnd, + &(sbuf->st_ex_ino), + sizeof(sbuf->st_ex_ino)); + if (rc < 0) { + gnutls_hash_deinit(hash_hnd, NULL); + goto out; + } + rc = gnutls_hash(hash_hnd, + upper_sname, + talloc_get_size(upper_sname) - 1); + if (rc < 0) { + gnutls_hash_deinit(hash_hnd, NULL); + goto out; + } + + gnutls_hash_deinit(hash_hnd, hash); /* Hopefully all the variation is in the lower 4 (or 8) bytes! */ memcpy(&result, hash, sizeof(result)); + ZERO_ARRAY(hash); DBG_DEBUG("fruit_inode \"%s\": ino=%ju\n", sname, (uintmax_t)result); +out: + TALLOC_FREE(upper_sname); + return result; } |