Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp952530pxv; Thu, 15 Jul 2021 21:00:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwvhv1BN4Bv1XyCH2w+lKRc67UlzVaUQlDnDZaMmCQjD+6l4PfLJKaXR9q5blbRX5mGUq1w X-Received: by 2002:a17:906:c7c2:: with SMTP id dc2mr5217405ejb.472.1626408005689; Thu, 15 Jul 2021 21:00:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626408005; cv=none; d=google.com; s=arc-20160816; b=j0PYQwmWUEfI5QrKlxIEf9cphVgNMxr3iVblRWUWSLkKrQrB0DHWpXxF4/RLJ5aw9K STO7uP5Etlw2lDeX8fWnknjavO8GFv7fkr3/V94FAYKsyjkw6A3A8hCAwKqvuCRmM+99 4auulDXfxtSl+gj5ViSUFVNwrEHblLCjqLsziQKUnuq74FJ9ujXWVO/YEi2uYnYdh4ql 4FwRfTGLTK2F/vVZorBhbk6/rFa+0N11gopBM0KWJOhAOBxLKkCvrZMLX1lVeCJrh8P0 U83LgfAWmVb8xEJBVFQ2Dbnox5/Kpu3O5T9cug8612J+OdfCt2zCT7DZkJSaQxEYNDCo Z51A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=2t8T9qkbU7ptQyFnJhfFGaRW5kuMlaxksd6X+kunyyk=; b=YRmu8yQ7hptudQTX8h/o67X+J0kCLE4ErvgjnbnIQDF1rfOd0LoNNMXaLgVb/LLh9i rKAG9fnv7id+lwRms/aLVYYRj5P4G9ie8rRnNol8fndiz41y2R8fwc+GwNjY5qx5AMSk 1gW/ym+dpDbCWXKryRqg02bQohE6U2Q0KtN6ReTwToBuYHDEE0M4Nqr5yTCmthYaf4wF 6GlKAqUIdATDZdYhSdysbbuVBgR8meUskCugn7cRyyPDV197CRU60HeJdU5SYJ31O6IR /Nu6f8qZC0Ml1LHpwB6FPKr6Lz5G6T13l9Ll1+fIyhPAtyU+LchmaL0dAIaxUn+zLL/q VHlg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i18si10011438edr.261.2021.07.15.20.59.42; Thu, 15 Jul 2021 21:00:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229578AbhGPEBt (ORCPT + 99 others); Fri, 16 Jul 2021 00:01:49 -0400 Received: from outgoing-auth-1.mit.edu ([18.9.28.11]:39829 "EHLO outgoing.mit.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229507AbhGPEBs (ORCPT ); Fri, 16 Jul 2021 00:01:48 -0400 Received: from callcc.thunk.org (96-65-121-81-static.hfc.comcastbusiness.net [96.65.121.81]) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 16G3wjI1028804 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 Jul 2021 23:58:46 -0400 Received: by callcc.thunk.org (Postfix, from userid 15806) id 505204202F5; Thu, 15 Jul 2021 23:58:45 -0400 (EDT) Date: Thu, 15 Jul 2021 23:58:45 -0400 From: "Theodore Y. Ts'o" To: wuguanghao Cc: linux-ext4@vger.kernel.org, artem.blagodarenko@gmail.com, liuzhiqiang26@huawei.com, linfeilong@huawei.com Subject: Re: [PATCH v2 11/12] misc/lsattr: check whether path is NULL in lsattr_dir_proc() Message-ID: References: <20210630082724.50838-2-wuguanghao3@huawei.com> <20210630082724.50838-12-wuguanghao3@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210630082724.50838-12-wuguanghao3@huawei.com> Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Wed, Jun 30, 2021 at 04:27:23PM +0800, wuguanghao wrote: > > diff --git a/misc/lsattr.c b/misc/lsattr.c > index 0d954376..f3212069 100644 > --- a/misc/lsattr.c > +++ b/misc/lsattr.c > @@ -144,6 +144,12 @@ static int lsattr_dir_proc (const char * dir_name, struct dirent * de, > int dir_len = strlen(dir_name); > > path = malloc(dir_len + strlen (de->d_name) + 2); > + if (!path) { > + fprintf(stderr, "%s", > + _("Couldn't allocate path variable " > + "in lsattr_dir_proc")); > + return -1; > + } The string is missing a closing newline. Also, why not? fputs(_("Couldn't allocate path variable in lsattr_dir_proc"), stderr); - Ted