The branch, master has been updated
via 6cd9849b58e lib:util: Fix stack-use-after-return in
crypt_as_best_we_can()
from 775e08ec7b6 vfs_ceph_new: add smbprofile for async-ops
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 6cd9849b58ec653cbffc602e3c96996a082faf53
Author: Andreas Schneider <[email protected]>
Date: Fri Jan 17 13:28:30 2025 +0100
lib:util: Fix stack-use-after-return in crypt_as_best_we_can()
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15784
Signed-off-by: Andreas Schneider <[email protected]>
Reviewed-by: Douglas Bagnall <[email protected]>
Reviewed-by: Pavel Filipenský <[email protected]>
Autobuild-User(master): Douglas Bagnall <[email protected]>
Autobuild-Date(master): Fri Jan 17 23:21:13 UTC 2025 on atb-devel-224
-----------------------------------------------------------------------
Summary of changes:
lib/util/util_crypt.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
Changeset truncated at 500 lines:
diff --git a/lib/util/util_crypt.c b/lib/util/util_crypt.c
index 09cd47597d1..9ac6e1cfd0e 100644
--- a/lib/util/util_crypt.c
+++ b/lib/util/util_crypt.c
@@ -1,11 +1,13 @@
#include <replace.h>
#include "data_blob.h"
+#include "discard.h"
#include <talloc.h>
#include <crypt.h>
#include "util_crypt.h"
-static int crypt_as_best_we_can(const char *phrase,
+static int crypt_as_best_we_can(TALLOC_CTX *mem_ctx,
+ const char *phrase,
const char *setting,
const char **hashp)
{
@@ -63,8 +65,14 @@ static int crypt_as_best_we_can(const char *phrase,
ret = ENOTRECOVERABLE;
}
}
+ if (ret != 0) {
+ return ret;
+ }
- *hashp = hash;
+ *hashp = talloc_strdup(mem_ctx, hash);
+ if (*hashp == NULL) {
+ ret = -1;
+ }
return ret;
}
@@ -75,14 +83,14 @@ int talloc_crypt_blob(TALLOC_CTX *mem_ctx,
DATA_BLOB *blob)
{
const char *hash = NULL;
- int ret = crypt_as_best_we_can(phrase, setting, &hash);
+ int ret = crypt_as_best_we_can(mem_ctx, phrase, setting, &hash);
if (ret != 0) {
blob->data = NULL;
blob->length = 0;
return ret;
}
blob->length = strlen(hash);
- blob->data = talloc_memdup(mem_ctx, hash, blob->length);
+ blob->data = discard_const_p(uint8_t, hash);
if (blob->data == NULL) {
return ENOMEM;
}
--
Samba Shared Repository