Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.4 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 233D9C35242 for ; Fri, 14 Feb 2020 21:41:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DE4FF206CC for ; Fri, 14 Feb 2020 21:41:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="f1znGFl1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387936AbgBNVl0 (ORCPT ); Fri, 14 Feb 2020 16:41:26 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:47112 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2387782AbgBNVl0 (ORCPT ); Fri, 14 Feb 2020 16:41:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581716485; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BomfLYK/UZESkoUrjqiyh58X5ye6kxP4uTsu1duDtQw=; b=f1znGFl1avb1g4MbGXMp3y+g0+dM6Lkb69O0Ck8qKiJYW8UqtVd4NOly8NYOF0An053/zP o00sNjaTgQDmPL0MnX4Ox/w/fKJGKtgn/0Wz5zKBn3ZXM7x9oaVBDAIHGF90eY6zspekGu wf8i77DcsEfWEsTW7H0X1okwYjPU1R8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-270-_ZVgo22fNg23w2LZt8IYmg-1; Fri, 14 Feb 2020 16:41:19 -0500 X-MC-Unique: _ZVgo22fNg23w2LZt8IYmg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 42DBB1005512 for ; Fri, 14 Feb 2020 21:41:17 +0000 (UTC) Received: from madhat.boston.devel.redhat.com (ovpn-117-182.phx2.redhat.com [10.3.117.182]) by smtp.corp.redhat.com (Postfix) with ESMTP id 11B115C1C3 for ; Fri, 14 Feb 2020 21:41:16 +0000 (UTC) Subject: Re: [PATCH] gssd: Closed a memory leak in find_keytab_entry() To: Linux NFS Mailing list References: <20200212190515.7443-1-steved@redhat.com> From: Steve Dickson Message-ID: Date: Fri, 14 Feb 2020 16:41:16 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <20200212190515.7443-1-steved@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On 2/12/20 2:05 PM, Steve Dickson wrote: > When 'adhostoverride' is "not set", which > is most of the time, adhostoverride is not freed. > > Signed-off-by: Steve Dickson Committed... stesved > --- > utils/gssd/krb5_util.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/utils/gssd/krb5_util.c b/utils/gssd/krb5_util.c > index a1c43d2..85f60ae 100644 > --- a/utils/gssd/krb5_util.c > +++ b/utils/gssd/krb5_util.c > @@ -799,7 +799,7 @@ find_keytab_entry(krb5_context context, krb5_keytab kt, > int tried_all = 0, tried_default = 0, tried_upper = 0; > krb5_principal princ; > const char *notsetstr = "not set"; > - char *adhostoverride; > + char *adhostoverride = NULL; > > > /* Get full target hostname */ > @@ -827,7 +827,6 @@ find_keytab_entry(krb5_context context, krb5_keytab kt, > adhostoverride); > /* No overflow: Windows cannot handle strings longer than 19 chars */ > strcpy(myhostad, adhostoverride); > - free(adhostoverride); > } else { > strcpy(myhostad, myhostname); > for (i = 0; myhostad[i] != 0; ++i) { > @@ -836,6 +835,8 @@ find_keytab_entry(krb5_context context, krb5_keytab kt, > myhostad[i] = '$'; > myhostad[i+1] = 0; > } > + if (adhostoverride) > + krb5_free_string(context, adhostoverride); > > if (!srchost) { > retval = get_full_hostname(myhostname, myhostname, sizeof(myhostname)); >