From b2b6599f873bd28008d8d26c073122ce363e9876 Mon Sep 17 00:00:00 2001 From: Nicolas Williams Date: Tue, 15 Sep 2020 11:26:06 -0500 Subject: [PATCH] krb5: Fix NULL deref on ENOMEM in fkt_add_entry(2) --- lib/krb5/keytab_file.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/krb5/keytab_file.c b/lib/krb5/keytab_file.c index c6beae947..e5ab569a5 100644 --- a/lib/krb5/keytab_file.c +++ b/lib/krb5/keytab_file.c @@ -582,6 +582,10 @@ fkt_add_entry(krb5_context context, return ret; } sp = krb5_storage_stdio_from_fd(fd, "wb+"); + if (sp == NULL) { + (void) close(fd); + return ret; + } krb5_storage_set_eof_code(sp, KRB5_KT_END); ret = krb5_ret_int8(sp, &pvno); if(ret) {