Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp610687pxt; Fri, 6 Aug 2021 09:23:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJygLCLif3W0bV9qAzNLC1K+tN5t63h2LhvUSaTJBCNLAf6PZroswUmBEU7DxYo9xnO8iiqK X-Received: by 2002:a02:c6d5:: with SMTP id r21mr10585057jan.71.1628266986398; Fri, 06 Aug 2021 09:23:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628266986; cv=none; d=google.com; s=arc-20160816; b=oYY1RJ9C2mZJ/1YLIB4UUtd/cRHrBFdqcd4And+48i/rqnmhswMZfu+s6DvwITnxRE AEfuVNAf5XV60mzbPbwmBj730HW34IcJGDB1hz+V2ktrsOToZ8ZwG/8KG24qibaYO5gC 21PyWQ9IggimdsocXHxez6r9ouGfNwtS1EmYGijNQ7iSPlw2W7eLKqdsQeptaO+ZklqZ QQ5YMRCeIGGPfDLCP+Ls5fR2aYki2nXC1jugR5ZZ7vn8U/M4b7wYA+p0qgJxS4yRD6ln Ww/ysbqxQGTy6lKCF9czcbwenyHuIXzY/qhCCePgSiUYSmZXwGYWgz6oLZVRdvTLW5qs mIiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :dkim-signature; bh=zCJcYHDj5auKge+/03UDfyPE2VgSp2GxYsZu4Bcf2fo=; b=vkWcs++I6Zkz8jJGxEnDScMSrdjix+UlmsfZjSbqUwBQaeoQf/HP/nss/2O4V7vFRB e+FFjAHKNvxvf9QVqVOJiexv8spzo+0pheNufuwdhGi84tcjaPQyiL+G5v61PJaHnh6R hDG0OFNwwPlcIS4B0tjEGQ4qCN57FuNhKf2Lh7s0iicxS2m9LNTGpbtKzqAggN26t6qd nZTAy0DYRWiofjdpvO2GyUQXy3I1wvzFG3JAZWkkIbaoGsBMErQ/LXOptMHRDsnR0ddw i0r4u62EBiKhLbG1BEsboREac0F1dycjXZvJVIOyoUI+ij9iUS10NC4/MF/bPaMddJwp 4rNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="PUXWm/sr"; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x4si8631457ilh.33.2021.08.06.09.22.52; Fri, 06 Aug 2021 09:23:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="PUXWm/sr"; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343704AbhHFMcm (ORCPT + 99 others); Fri, 6 Aug 2021 08:32:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:54609 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343699AbhHFMcm (ORCPT ); Fri, 6 Aug 2021 08:32:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628253146; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zCJcYHDj5auKge+/03UDfyPE2VgSp2GxYsZu4Bcf2fo=; b=PUXWm/srwrR5z0p2lLp80hf0iA0SC3fj8TR5f+KL/9n49wv65yquwS8ZOPMuvqMAxye7Db TNo6y4zIBKcmQd+fwei1+ahzorQt+p2w3IsxvPAwYrcUOV7TifguKs9ujRDpKczPadVCIl vmgOvXrQNzBTu4gJEF9EFGS8OPeSJ8w= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-51-wAnAUSLPPKOrl9w0WEtAeg-1; Fri, 06 Aug 2021 08:32:25 -0400 X-MC-Unique: wAnAUSLPPKOrl9w0WEtAeg-1 Received: by mail-wr1-f72.google.com with SMTP id o11-20020a5d474b0000b02901533f8ed22cso3093432wrs.22 for ; Fri, 06 Aug 2021 05:32:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:mime-version:content-transfer-encoding; bh=zCJcYHDj5auKge+/03UDfyPE2VgSp2GxYsZu4Bcf2fo=; b=e5KgxPirJmzwCkTsC5fNhMEYiZcjlobao6RXNjbE/bxy/uPpCu4OQ2vzwuJcmny2u2 Abmc7vBAZBnmsKz6hp+EPX81mxgwtP5eHsb7AicE4tJ67E4SZGGccvrAyc9rI4Iew//5 +wrqtW3Xoq2B1mCBvg7Gm/zmt4za43OqvmRq0t/abNBwkGDEL2k8dJOFjKiWTX0GDHmZ d7EDI3O7e6ssGDUQ3dBQAZV9TdovIEz/8nn2L+niG34Um/ULuSBW6bqQHy7KeYKMXhBF XyyW5KxM8GHIcL/kNfo4KkGahbzFqHW5uIrJ4eljCDQMLWbCvmxJbf6uFL2JMbya5ujy s9TQ== X-Gm-Message-State: AOAM533JV2ASyBHIOKA5dQx6qiFPhX1UoRnvXHG8w7IpJbOdLXHOzAx9 yuEr9Pb8mGcrn4+8sefWToauW8c/aEQWANcsQjn80eTbrh6W6PkWi0lHzAcIZYY8KXnd8GiiCJt ZBj0JQRBKJfdNyB3FjICw5cgB40UJbQ36SuM6JHNYFegq+gmAEZbGvDbStfw8OzVSjYmVvqhv2S Q= X-Received: by 2002:adf:f845:: with SMTP id d5mr10376403wrq.267.1628253143776; Fri, 06 Aug 2021 05:32:23 -0700 (PDT) X-Received: by 2002:adf:f845:: with SMTP id d5mr10376383wrq.267.1628253143623; Fri, 06 Aug 2021 05:32:23 -0700 (PDT) Received: from ajmitchell.remote.csb ([95.145.245.173]) by smtp.gmail.com with ESMTPSA id s14sm8212809wmc.25.2021.08.06.05.32.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Aug 2021 05:32:23 -0700 (PDT) Message-ID: Subject: [PATCH 2/4] nfs-utils: Fix mem leaks in gssd From: Alice Mitchell To: linux-nfs@vger.kernel.org Cc: Steve Dickson Date: Fri, 06 Aug 2021 13:32:22 +0100 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5 (3.28.5-16.el8) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Also fix the modification of a returned config value which should be treated as const. Signed-off-by: Alice Mitchell --- utils/gssd/gssd.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/utils/gssd/gssd.c b/utils/gssd/gssd.c index 4113cba..0815665 100644 --- a/utils/gssd/gssd.c +++ b/utils/gssd/gssd.c @@ -1016,7 +1016,7 @@ read_gss_conf(void) keytabfile = s; s = conf_get_str("gssd", "cred-cache-directory"); if (s) - ccachedir = s; + ccachedir = strdup(s); s = conf_get_str("gssd", "preferred-realm"); if (s) preferred_realm = s; @@ -1070,7 +1070,7 @@ main(int argc, char *argv[]) keytabfile = optarg; break; case 'd': - ccachedir = optarg; + ccachedir = strdup(optarg); break; case 't': context_timeout = atoi(optarg); @@ -1133,7 +1133,6 @@ main(int argc, char *argv[]) } if (ccachedir) { - char *ccachedir_copy; char *ptr; for (ptr = ccachedir, i = 2; *ptr; ptr++) @@ -1141,8 +1140,7 @@ main(int argc, char *argv[]) i++; ccachesearch = malloc(i * sizeof(char *)); - ccachedir_copy = strdup(ccachedir); - if (!ccachedir_copy || !ccachesearch) { + if (!ccachesearch) { printerr(0, "malloc failure\n"); exit(EXIT_FAILURE); } @@ -1274,6 +1272,8 @@ main(int argc, char *argv[]) free(preferred_realm); free(ccachesearch); + if (ccachedir) + free(ccachedir); return rc < 0 ? EXIT_FAILURE : EXIT_SUCCESS; } -- 2.27.0