lib/krb5_wrap: Check return value of krb5_principal_get_comp_string()
authorJoseph Sutton <josephsutton@catalyst.net.nz>
Wed, 20 Sep 2023 23:02:38 +0000 (11:02 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 26 Oct 2023 01:24:32 +0000 (01:24 +0000)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15482

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/krb5_wrap/krb5_samba.c

index 1d19e477743b48d68d538348b3d9f8a6a8169e72..062e05ead34a6a48ee0b6e982148f5d7e9037f40 100644 (file)
@@ -1058,7 +1058,14 @@ char *smb_krb5_principal_get_comp_string(TALLOC_CTX *mem_ctx,
                                         unsigned int component)
 {
 #if defined(HAVE_KRB5_PRINCIPAL_GET_COMP_STRING)
-       return talloc_strdup(mem_ctx, krb5_principal_get_comp_string(context, principal, component));
+       const char *str = NULL;
+
+       str = krb5_principal_get_comp_string(context, principal, component);
+       if (str == NULL) {
+               return NULL;
+       }
+
+       return talloc_strdup(mem_ctx, str);
 #else
        krb5_data *data;