Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1269154imm; Sun, 15 Jul 2018 03:40:26 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcdL+O7j5EFD36pbG/7p8b/Xi3ANKI5biLO452p+pbUbq8mK9YwGtfqpyQUX9M2MULS5U5H X-Received: by 2002:a63:4f1a:: with SMTP id d26-v6mr12308593pgb.121.1531651226108; Sun, 15 Jul 2018 03:40:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531651226; cv=none; d=google.com; s=arc-20160816; b=enMCI0pNT6/9sxr/3ZGssoJbR3lu9Ptfp+EezSk/mm9jMlSejx0culHmT61BWc/PdU uY4pRZW+l+zOMHHV+z8/AxMW6/8os6ObLQR9Ds777vRuiwMKkXbeBzFS1PaDpT1VwVOu KbOFrempUS5rof7jQJLfBzajFqNBGTXtUNC95fQvwqwbc8tdRHJohqr8OU+MyeD7nrGO dpqL7HnrolzhiqCSJCnco06n0o07dGl9noaRiopMHrHSg9uqrwrYBZdj8colrTBl9LCp Q92rTob/IPFp5150/29kxj1+lxgIqWR1uRMszulJ6TvUfz8Olz3fA74U3WvJHtaDuYt2 jmDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature:arc-authentication-results; bh=OZ1AFG5nwPrV+yv1ycNHYZwGFkndTE2d760GMr+f/vk=; b=MmmCcs0rVqAfLG7ND7KGMI/p8ZwyndL152tEdOxRd+kttI+0z6v+Nu53W+wTPvsSPq U7MNIzMGcYXLKvwDa2l4Y72Pv6kJBPxvAX9fjM2nb8tGYXnOJmej5kI9QKXbeg2SbBIu n96tSj8/+2d9IuNLwRyOB4izsKY9kWuNx8fhhrrO+QrSROobJzmmEMoWc+rboPl+lXjV QelZ9X3pvBJ7E0ooRmn4ehIy3kHd89NILiw/ILP9pHssAQGJN+IimaArz4x37rx35aPV 0B4EeX4nZGAaiGW9eeHsDUof9Ly0uP/vOWmSiSSphD7R9Y0JVP7+/wblencs18RCY1u8 u/Ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=NaoHBIEo; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s2-v6si26779725pgc.447.2018.07.15.03.40.11; Sun, 15 Jul 2018 03:40:26 -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; dkim=pass header.i=@kernel.org header.s=default header.b=NaoHBIEo; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726201AbeGOLCJ (ORCPT + 99 others); Sun, 15 Jul 2018 07:02:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:48882 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726106AbeGOLCI (ORCPT ); Sun, 15 Jul 2018 07:02:08 -0400 Received: from archlinux (cpc91196-cmbg18-2-0-cust659.5-4.cable.virginm.net [81.96.234.148]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7E94E208C2; Sun, 15 Jul 2018 10:39:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1531651177; bh=KCRAt0UEQ/TpWDORYeh1hOZijBS/J3eJ1lc2bFedDmg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=NaoHBIEov1kGOYbwlY67Ky5b9r+uA1DOqrAZgNsxyzn5Hhykg4KioBl5ulkOAGApp NzKxhN0jaJJ4mQI5/mM3LDj0TEu+LLZRZlQdmua+tB2vaX20qUYtUf5zkEqPwQsj24 5JgI+x7YlNAWNedWrSz0fmwZqeCk8WQKw91kfrTw= Date: Sun, 15 Jul 2018 11:39:32 +0100 From: Jonathan Cameron To: Dominique Martinet Cc: Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Lorenzo Bianconi , Linus Walleij , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 05/18] iio: change strncpy+truncation to strlcpy Message-ID: <20180715113907.3813384d@archlinux> In-Reply-To: <1531445134-19250-1-git-send-email-asmadeus@codewreck.org> References: <1531444483-17338-1-git-send-email-asmadeus@codewreck.org> <1531445134-19250-1-git-send-email-asmadeus@codewreck.org> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 13 Jul 2018 03:25:34 +0200 Dominique Martinet wrote: > Generated by scripts/coccinelle/misc/strncpy_truncation.cocci > > Signed-off-by: Dominique Martinet Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it. Thanks, Jonathan > --- > > Please see https://marc.info/?l=linux-kernel&m=153144450722324&w=2 (the > first patch of the serie) for the motivation behind this patch > > drivers/iio/common/st_sensors/st_sensors_core.c | 3 +-- > drivers/iio/pressure/st_pressure_i2c.c | 3 +-- > 2 files changed, 2 insertions(+), 4 deletions(-) > > diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c > index 57db19182e95..26fbd1bd9413 100644 > --- a/drivers/iio/common/st_sensors/st_sensors_core.c > +++ b/drivers/iio/common/st_sensors/st_sensors_core.c > @@ -380,8 +380,7 @@ void st_sensors_of_name_probe(struct device *dev, > return; > > /* The name from the OF match takes precedence if present */ > - strncpy(name, of_id->data, len); > - name[len - 1] = '\0'; > + strlcpy(name, of_id->data, len); > } > EXPORT_SYMBOL(st_sensors_of_name_probe); > #else > diff --git a/drivers/iio/pressure/st_pressure_i2c.c b/drivers/iio/pressure/st_pressure_i2c.c > index fbb59059e942..2026a1012012 100644 > --- a/drivers/iio/pressure/st_pressure_i2c.c > +++ b/drivers/iio/pressure/st_pressure_i2c.c > @@ -94,9 +94,8 @@ static int st_press_i2c_probe(struct i2c_client *client, > if ((ret < 0) || (ret >= ST_PRESS_MAX)) > return -ENODEV; > > - strncpy(client->name, st_press_id_table[ret].name, > + strlcpy(client->name, st_press_id_table[ret].name, > sizeof(client->name)); > - client->name[sizeof(client->name) - 1] = '\0'; > } else if (!id) > return -ENODEV; >