Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp241777imm; Thu, 12 Jul 2018 18:27:13 -0700 (PDT) X-Google-Smtp-Source: AAOMgpffFg2yWyJKEwXW4F6ajauBWDkXm/mXx5rRkNgty1ZobOk9NHrgKO9OX3jDHbhYLXe1dCjm X-Received: by 2002:a17:902:4c88:: with SMTP id b8-v6mr4171870ple.285.1531445233592; Thu, 12 Jul 2018 18:27:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531445233; cv=none; d=google.com; s=arc-20160816; b=wwjMH8vJU31C8NxB63oC6b9aKRUf+k9tMTr2sV6A6q00nwTBQU8oZis/ccRtXYJJT7 AMIQw7C1RHkTol2S2OLHH8EWoNSxGFGAipo+RgU2Ade/swdFvWY09kVCp0wVy4K8z/li SNmqxuX68okDprgTbYhJeA4ZlXUuPNT+VYm1xHT046xmjKTHqdBHuHurWs9bd0H6ZVfo Kjp5G1l1BMaov4FUGbh/H6OM3s2aAScbiOrgk6dAJ7CnlcQZjweoG19OYoHQCaNx77rc PLf7WCAtHXPG/YT1Qt6NsGbmdETz5GJ3MYaC2gQCG33yD6cTRI/3KarP7lgJDm8jO68j 7vzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from :arc-authentication-results; bh=68AJ/y7DiiceBzAUvquB+1PEAp4zytqU4Lf1iuCj3dU=; b=gXNrsMpaxlro6RrC+oLEKBZmBk0yWc1wrABiQqJVpP1N0Vm2wPoEAkSocCFIb0pImk GPT7aTMOrYsMDrLwEueEFcu1smZZKhEDx1rrZxlBBngqYynCzynBZGaF64gvJgNQao0n V1DXAEJWfMN/9L933JJfyWjkF71SMNu14CJ73Wr7U+1M4kUXPa4RfKZ5n2LRINhXagZZ wb7mNH/GSqOnkwpAJLV1mtr6E678FNmRO6a494TT+aQM1IPYSMlNryNoWnnJS4Kp8/0h DmoOPddGbvSs3qe6XIUMIaPkVQSkDawqeW6XcvExCGkxxww3O5fVQWNJJ4YikKGAMLCM IrfA== 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 x128-v6si23161909pgx.156.2018.07.12.18.26.58; Thu, 12 Jul 2018 18:27:13 -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 S2388158AbeGMBiQ (ORCPT + 99 others); Thu, 12 Jul 2018 21:38:16 -0400 Received: from nautica.notk.org ([91.121.71.147]:43041 "EHLO nautica.notk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387896AbeGMBiP (ORCPT ); Thu, 12 Jul 2018 21:38:15 -0400 Received: by nautica.notk.org (Postfix, from userid 1001) id 04900C02A; Fri, 13 Jul 2018 03:26:03 +0200 (CEST) From: Dominique Martinet Cc: Dominique Martinet , Jens Axboe , Steven Rostedt , Ingo Molnar , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: =?UTF-8?q?=5BPATCH=2015/18=5D=20blktrace=3A=20change=20strncpy+truncation=20to=20strlcpy?= Date: Fri, 13 Jul 2018 03:26:02 +0200 Message-Id: <1531445162-19771-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> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Using strlcpy fixes this new gcc warning: kernel/trace/blktrace.c: In function ‘do_blk_trace_setup’: kernel/trace/blktrace.c:497:2: warning: ‘strncpy’ specified bound 32 equals destination size [-Wstringop-truncation] strncpy(buts->name, name, BLKTRACE_BDEV_SIZE); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 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 kernel/trace/blktrace.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c index 987d9a9ae283..2478d9838eab 100644 --- a/kernel/trace/blktrace.c +++ b/kernel/trace/blktrace.c @@ -494,8 +494,7 @@ static int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev, if (!buts->buf_size || !buts->buf_nr) return -EINVAL; - strncpy(buts->name, name, BLKTRACE_BDEV_SIZE); - buts->name[BLKTRACE_BDEV_SIZE - 1] = '\0'; + strlcpy(buts->name, name, BLKTRACE_BDEV_SIZE); /* * some device names have larger paths - convert the slashes -- 2.17.1