Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp241122imm; Thu, 12 Jul 2018 18:26:02 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeT6lZrIHbtSKAEMgMK6QDIVouwLHzJSPZSzSmfbZgh6kaL0SNoXEcyBL+bOMUlVVnIuNzM X-Received: by 2002:a62:ec41:: with SMTP id k62-v6mr4769881pfh.206.1531445162417; Thu, 12 Jul 2018 18:26:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531445162; cv=none; d=google.com; s=arc-20160816; b=iaryzSsUhTFOxi/JsjGh069UQhL6povCaeELl8wZ5rmAnGM2EqyDB3YHoREnzmcYvZ Jb8JzYA5tFgzzOfzTicyxRAjD8qEG4fRZPvfcR2S5LVhi8ADPhqtsn1gbz36s7oDIEPo OjRGFiMn+x1EUsRVJEPNvtJoX/eiw+CKm41V6ArS8oMCVi3bLMGmFnZmnxOJSCGhG8XY rPV7H9VrPuAUU327wJ1EqLvbKJbKCporoIzted+MQTkdghwU2MKz04Llcoq+HhQRvR0i 99bOmbHAhEA9WgeXPN4fb/zucCRRvf7n/+lkLIr8rQFc6x0Kp+szsy6/09/xJf5Yc+CU EJBA== 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=pZzSsI05mp4I+9qRV+aFOcDyL+YsoaB35ucOvFStIEw=; b=dpBv6osWpkzLwgdxb9nPVoVZFaz0U6T2o3UEepXHsbzUSWEytK8t4lv1GAEwJMYlcb dsEqlTDHJdB1NwaoKXIBvOf5ehxk/ssTLH9b00JuzM26Gv0m0ETNNIyXmud7NSSLa8gU eBgki3ENgP3dttLPiFX75vKOu5ZYgpBzwmMAxa02rSTGDxGbLJW2Z3sMpFLKah7RyvnH tIchttI27LJdpF8qKF5rRZzGJfRchktnDbVBtbmdfrMPCqmqBytzD2BbO2dnB/JW7cXD iT0SkmzYed52LWdJd+mQZdOos2pg5W+H5i8hwr7HWhei127ZX+yLfCOzn1d7ZBHLY3Qy bn/w== 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 k14-v6si8728982pga.149.2018.07.12.18.25.47; Thu, 12 Jul 2018 18:26:02 -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 S2387926AbeGMBhY (ORCPT + 99 others); Thu, 12 Jul 2018 21:37:24 -0400 Received: from nautica.notk.org ([91.121.71.147]:42970 "EHLO nautica.notk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387896AbeGMBhY (ORCPT ); Thu, 12 Jul 2018 21:37:24 -0400 Received: by nautica.notk.org (Postfix, from userid 1001) id D7EE6C009; Fri, 13 Jul 2018 03:25:10 +0200 (CEST) From: Dominique Martinet Cc: Dominique Martinet , "Ed L. Cashin" , Jens Axboe , Linus Walleij , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org Subject: [PATCH 02/18] block/aoenet: change strncpy+truncation to strlcpy Date: Fri, 13 Jul 2018 03:25:05 +0200 Message-Id: <1531445105-18941-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/block/aoe/aoenet.c | 3 +-- drivers/gpio/gpiolib.c | 12 ++++-------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/block/aoe/aoenet.c b/drivers/block/aoe/aoenet.c index 63773a90581d..1b2871056f8f 100644 --- a/drivers/block/aoe/aoenet.c +++ b/drivers/block/aoe/aoenet.c @@ -39,8 +39,7 @@ static struct ktstate kts; #ifndef MODULE static int __init aoe_iflist_setup(char *str) { - strncpy(aoe_iflist, str, IFLISTSZ); - aoe_iflist[IFLISTSZ - 1] = '\0'; + strlcpy(aoe_iflist, str, IFLISTSZ); return 1; } diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index e11a3bb03820..be08277699ff 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1015,12 +1015,10 @@ static long gpio_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) memset(&chipinfo, 0, sizeof(chipinfo)); - strncpy(chipinfo.name, dev_name(&gdev->dev), + strlcpy(chipinfo.name, dev_name(&gdev->dev), sizeof(chipinfo.name)); - chipinfo.name[sizeof(chipinfo.name)-1] = '\0'; - strncpy(chipinfo.label, gdev->label, + strlcpy(chipinfo.label, gdev->label, sizeof(chipinfo.label)); - chipinfo.label[sizeof(chipinfo.label)-1] = '\0'; chipinfo.lines = gdev->ngpio; if (copy_to_user(ip, &chipinfo, sizeof(chipinfo))) return -EFAULT; @@ -1036,16 +1034,14 @@ static long gpio_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) desc = &gdev->descs[lineinfo.line_offset]; if (desc->name) { - strncpy(lineinfo.name, desc->name, + strlcpy(lineinfo.name, desc->name, sizeof(lineinfo.name)); - lineinfo.name[sizeof(lineinfo.name)-1] = '\0'; } else { lineinfo.name[0] = '\0'; } if (desc->label) { - strncpy(lineinfo.consumer, desc->label, + strlcpy(lineinfo.consumer, desc->label, sizeof(lineinfo.consumer)); - lineinfo.consumer[sizeof(lineinfo.consumer)-1] = '\0'; } else { lineinfo.consumer[0] = '\0'; } -- 2.17.1