]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s4:kdc: Consistently zero HDB structures
authorJoseph Sutton <josephsutton@catalyst.net.nz>
Thu, 10 Aug 2023 04:35:52 +0000 (16:35 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Mon, 14 Aug 2023 04:57:34 +0000 (04:57 +0000)
To these conversion functions we sometimes pass malloc-allocated HDB
structures, which we free afterwards if conversion fails. If parts of
these structures are still uninitialized when we try to free them, all
sorts of fun things can result.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source4/kdc/sdb_to_hdb.c

index be7a6d4b912f0e98380664c889cafc7436a542c8..c5cc23fda7037344ef7155a0f37fdb06f16e5e29 100644 (file)
@@ -75,6 +75,8 @@ static int sdb_salt_to_Salt(const struct sdb_salt *s, Salt *h)
 {
        int ret;
 
+       ZERO_STRUCTP(h);
+
        h->type = s->type;
        ret = smb_krb5_copy_data_contents(&h->salt, s->salt.data, s->salt.length);
        if (ret != 0) {
@@ -126,6 +128,8 @@ static int sdb_keys_to_Keys(const struct sdb_keys *s, Keys *h)
 {
        int ret, i;
 
+       ZERO_STRUCTP(h);
+
        h->len = s->len;
        if (s->val != NULL) {
                h->val = malloc(h->len * sizeof(Key));
@@ -177,6 +181,8 @@ static int sdb_event_to_Event(krb5_context context,
 {
        int ret;
 
+       ZERO_STRUCTP(h);
+
        if (s->principal != NULL) {
                ret = krb5_copy_principal(context,
                                          s->principal,