Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp502926imm; Fri, 13 Jul 2018 01:02:48 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcJSz3ZFckifrd7WQpsQAi24EVRb3PM+2MDtGstxKD+Y0rK7qR/FntvJwRe9/GKEv0rIlyn X-Received: by 2002:a63:b705:: with SMTP id t5-v6mr5180949pgf.45.1531468968344; Fri, 13 Jul 2018 01:02:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531468968; cv=none; d=google.com; s=arc-20160816; b=WbgNbhnii2/+IAFoDwdrD3Lk8V1w3VdjHShJaZAh8Ua+Bws68wfzv4qfysyKzt5CjC JQzW7DSCFr2U/fav1ZA4txvZUkvm/tHo+MHHN072IgSGKlvfqdc317SyLXH+fHiVoGJ2 n+JPvTgEpbW+OTcOQtFH/X/Bi/b8FMdtWGtVKhi6AGiYkl2lxdcEFF0T1cy/y+5dCANZ xsjYjDtmorgvgsCM76qVE8CmUnbnhYeauki8TChLnnHpyGxpYDaFdCOv1BpXA+apWNow kn/DFMCXQ3hTTgHJQb0RdUGbA20GpxGKPRpQ7Z4tAWP9cf0/pO6GCpmOxEhzEdl3LLfO cClg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=OhBuXnYEqRLU99uFZxjjmQvm8T9xHksOgeRrYrNdmQs=; b=vXH6sMKAqE7FeMQOvn1E691MWiUS+XBXKBzCxiG25dtG3fRcTa87IAYLseRgda6Mid xiyN6h0jssmTQm6Yk0MalO1H0WTG658o3TADc91sjJiFFbt+4mSlGOC/sVWkuT08fe+D 8cPh6l1IStilTdTphtuMDe8gNFkSSCubjSulOrbIs3CBwcZ8zaaMX1vDAVsaHNIs53p8 DEi41dNkU8JIRPqrjIITKFPyIEwkQdU1OIARPqF+PMweEf/r5Nlsh86m3Ic9eMGQJGq8 0cJo6sp6ZjkEeo+XxkSwy1lo9f/LBug7G9cV+vt99n1AfqmitYwrnNF0pXZs+Ka5hz9p 0VXA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b129-v6si4593619pfa.12.2018.07.13.01.02.33; Fri, 13 Jul 2018 01:02:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387839AbeGMIOK (ORCPT + 99 others); Fri, 13 Jul 2018 04:14:10 -0400 Received: from nautica.notk.org ([91.121.71.147]:37818 "EHLO nautica.notk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731564AbeGMIOJ (ORCPT ); Fri, 13 Jul 2018 04:14:09 -0400 Received: by nautica.notk.org (Postfix, from userid 1001) id 10826C01A; Fri, 13 Jul 2018 10:00:38 +0200 (CEST) Date: Fri, 13 Jul 2018 10:00:23 +0200 From: Dominique Martinet To: Himanshu Jha Cc: Michal Marek , Nicolas Palix , linux-kernel@vger.kernel.org, cocci@systeme.lip6.fr, Ville =?utf-8?B?U3lyasOkbMOk?= Subject: Re: [Cocci] [PATCH 01/18] coccinelle: change strncpy+truncation to strlcpy Message-ID: <20180713080023.GB9638@nautica> References: <1531444483-17338-1-git-send-email-asmadeus@codewreck.org> <20180713074455.GA6859@himanshu-Vostro-3559> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20180713074455.GA6859@himanshu-Vostro-3559> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Himanshu Jha wrote on Fri, Jul 13, 2018: > > I expect each maintainer will pick their share of the patchs if they > > agree with it and the rest will just be dropped? > > Masahiro Yamada takes coccinelle patches, > so please cc him or your patch would be lost. Thanks, will do. > > +virtual patch > > +virtual context > > You might consider adding context rule or remove this line perhaps ? Victim of copypasta, I'll remove this. > > +-strncpy@p( > > ++strlcpy( > > + dest, src, sz); > > +-dest[sz - 1] = '\0'; > > The above rule produces an output that I think is not correct: > -------------------------------------------------------------- > diff = > diff -u -p a//ti/wl1251/acx.c b//ti/wl1251/acx.c > --- a//ti/wl1251/acx.c > +++ b//ti/wl1251/acx.c > @@ -150,14 +150,7 @@ int wl1251_acx_fw_version(struct wl1251 > } > > /* be careful with the buffer sizes */ > - strncpy(buf, rev->fw_version, min(len, sizeof(rev->fw_version))); > - > - /* > - * if the firmware version string is exactly > - * sizeof(rev->fw_version) long or fw_len is less than > - * sizeof(rev->fw_version) it won't be null terminated > - */ > - buf[min(len, sizeof(rev->fw_version)) - 1] = '\0'; > + strlcpy(buf, rev->fw_version, min(len, sizeof(rev->fw_version))); > > ----------------------------------------------------------------- > > I think the comment is useful and should not be removed. I agree this comment is useful now that I'm taking a closer look, I glanced at this too fast. I'm not sure how to make coccinelle not remove comments between lines though? > Also, consider changing Confidence level appropriately. I am (was?) pretty confident on the change itself, the only exceptions would be if someone relied on strncpy to fill the end of the buffer with zero to not leak data somewhere but that is not easy to judge by itself (although I hope rare enough) I'm honestly not sure what would be appropriate in this case. -- Dominique Martinet