Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp241536imm; Thu, 12 Jul 2018 18:26:48 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeFvEHzV+eDIA9vugcETULYM6bLfrRTtqE73oGZbBh1OOpKbP31cOs9iQ1tirRXTFhfbGzK X-Received: by 2002:a17:902:42a3:: with SMTP id h32-v6mr4288724pld.72.1531445208818; Thu, 12 Jul 2018 18:26:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531445208; cv=none; d=google.com; s=arc-20160816; b=xUZ4yPSodceV3FmqVgFLyOGsfsjYhhM49Qk0HZk5CkXx/uE+nH3MaYetWkePWk2h0f 1sQPcQpxZXABi8q+nC+KjH9LzUd8LdGoMdbqkDnSeoK++LK6DLixczvn/j9Pnyq6co7N FvzbwXaJ+e863zRzPsXMDvuOJRVSfn0nFq6MhS6MbWwKo5CWlbST5LuxVp7H4gTdelHS Kporv+V5CxGJ4ISeJSFTr1Gr4Kehmn6SHRvQzeCxIjQn7UccOrjYZ8bsLj3I4PDrQsLX fnRf7ajwc1zaKhxl0ci3UDmPq/XBCEmxyVr5BaifX4SCItNEHsczbVzpqXwB07Tro3l6 4XvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:in-reply-to:message-id:date :subject:cc:from:arc-authentication-results; bh=VeI7yk7WVpipHpKXhRiYWhGNyYWiZeeT2euQKK2Ims8=; b=YBc+99uncJr6sbWUpOaxfluUCV2FCZrudAbJu57e+eR2yZDwzDdczZUalD7oqXmz13 tWCq9y91VdzCxkvD8Vm982MiydTAmtM4IZCll5BPPEDuFqSJHHFMq6b0Ziil/n0weKVZ KZwy5D9yLH+oL/NhYAGmCz4guY2p3SO6qxq8zJhQ8Z0GR3J5l8OmUd7mLLd0S0yuYGGP LRKyItijzKdDml24HwbNEVw0gJNGR5zLALW9k/O2uwQDM0fTmCykOMfBxzJnMNGSbcNp xooZtcyKgSi55wie81KWoBsc24vhLQU83PFe4VtpyQkoJnquShMGiaMkYaXj2EtPeqsV ljWw== 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 c4-v6si2135734plr.405.2018.07.12.18.26.33; Thu, 12 Jul 2018 18:26: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 S2387985AbeGMBhs (ORCPT + 99 others); Thu, 12 Jul 2018 21:37:48 -0400 Received: from nautica.notk.org ([91.121.71.147]:42986 "EHLO nautica.notk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387896AbeGMBhs (ORCPT ); Thu, 12 Jul 2018 21:37:48 -0400 Received: by nautica.notk.org (Postfix, from userid 1001) id 984D9C01E; Fri, 13 Jul 2018 03:25:35 +0200 (CEST) From: Dominique Martinet Cc: Dominique Martinet , Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Lorenzo Bianconi , Linus Walleij , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 05/18] iio: change strncpy+truncation to strlcpy Date: Fri, 13 Jul 2018 03:25:34 +0200 Message-Id: <1531445134-19250-1-git-send-email-asmadeus@codewreck.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1531444483-17338-1-git-send-email-asmadeus@codewreck.org> References: <1531444483-17338-1-git-send-email-asmadeus@codewreck.org> To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Generated by scripts/coccinelle/misc/strncpy_truncation.cocci Signed-off-by: Dominique Martinet --- 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; -- 2.17.1