167d4b
From f1bde6a617471740e895aacc2e679b0f2d0c07a5 Mon Sep 17 00:00:00 2001
167d4b
From: Matt Rogers <mrogers@redhat.com>
167d4b
Date: Wed, 12 Nov 2014 17:21:05 +0100
167d4b
Subject: [PATCH] s3-keytab: fix keytab array NULL termination.
167d4b
167d4b
Signed-off-by: Matt Rogers <mrogers@redhat.com>
167d4b
Reviewed-by: Guenther Deschner <gd@samba.org>
167d4b
---
167d4b
 source3/libads/kerberos_keytab.c | 3 +--
167d4b
 1 file changed, 1 insertion(+), 2 deletions(-)
167d4b
167d4b
diff --git a/source3/libads/kerberos_keytab.c b/source3/libads/kerberos_keytab.c
167d4b
index 43c755c..ae3d80e39 100644
167d4b
--- a/source3/libads/kerberos_keytab.c
167d4b
+++ b/source3/libads/kerberos_keytab.c
167d4b
@@ -667,14 +667,13 @@ int ads_keytab_create_default(ADS_STRUCT *ads)
167d4b
 		goto done;
167d4b
 	}
167d4b
 
167d4b
-	oldEntries = talloc_array(frame, char *, found);
167d4b
+	oldEntries = talloc_zero_array(frame, char *, found + 1);
167d4b
 	if (!oldEntries) {
167d4b
 		DEBUG(1, (__location__ ": Failed to allocate space to store "
167d4b
 			  "the old keytab entries (talloc failed?).\n"));
167d4b
 		ret = -1;
167d4b
 		goto done;
167d4b
 	}
167d4b
-	memset(oldEntries, '\0', found * sizeof(char *));
167d4b
 
167d4b
 	ret = krb5_kt_start_seq_get(context, keytab, &cursor);
167d4b
 	if (ret == KRB5_KT_END || ret == ENOENT) {
167d4b
-- 
167d4b
1.9.3
167d4b