From: Joseph Sutton Date: Wed, 20 Sep 2023 23:02:38 +0000 (+1200) Subject: lib/krb5_wrap: Check return value of krb5_principal_get_comp_string() X-Git-Tag: talloc-2.4.2~1011 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=800f3203b1dd61531e7b861738558e751e45f8af;p=thirdparty%2Fsamba.git lib/krb5_wrap: Check return value of krb5_principal_get_comp_string() BUG: https://bugzilla.samba.org/show_bug.cgi?id=15482 Signed-off-by: Joseph Sutton Reviewed-by: Andrew Bartlett --- diff --git a/lib/krb5_wrap/krb5_samba.c b/lib/krb5_wrap/krb5_samba.c index 1d19e477743..062e05ead34 100644 --- a/lib/krb5_wrap/krb5_samba.c +++ b/lib/krb5_wrap/krb5_samba.c @@ -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;