Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3990895imm; Tue, 29 May 2018 19:01:40 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIe684lcFHs+W8QDl1zxzU1C6MxwLXpWzl5JOxby+Mxdb+oJNp2fwW/MMhcV5CddgJ7dWqg X-Received: by 2002:a17:902:265:: with SMTP id 92-v6mr838869plc.368.1527645700025; Tue, 29 May 2018 19:01:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527645699; cv=none; d=google.com; s=arc-20160816; b=uvW45nh5Ubp6VHS9k/bNMpjbVQ6dsQc4AtxCBbTLcK/D4pj5vlIZ5uOjFsH0EO0jZP bhsTrE3rzKpLNLwam3LtZH73U3dJgQDsYTh4yxgwpZbo3Bjzn8K1BCcU4zVHuJSO4Ov6 h7BazmBX8vxnxozdLmFxZXAbiZhk/ZFwHuZEpjkd3tdxIU3MIoBdVeeZVFEcwnQcWrl+ B78m8Bv7KZ+LfGm/luGZ0dH1LXzhVKQNvVufacXBnDe+uIPd/gzcRDl1W1Er7yhQdvrl oWoGP1E+eI2bkOL8dHXREBfMXPdZQy6dZ+FlXL3NSD8nky5ERuPF4TXR74mdFgCpYn2y +c2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=Q/+r35UjzCD3/3JNoLCZg+73POxnL+Zl/G6ZiyVAZtw=; b=FnO9B37XZeqMee93ZthidZAJLQFrmT64KnU4CS9uDcpzkey2GCXVIKVa32/S5WGHTt 7NMVCDyzDobHG7hVSCxSYpjaEXf3Y90q/ezqahDY6/atU90MTHSXumGpwOa3wo4akzD5 1uQT1JW9cgoApbUwG402n+1+MakKE9LC33kjAN7aF/dLf1C9hms+78/Xz1NEjGOs2P4t iSCIRq2qa7xDMCuFaMmIHbDAvr8Nzys4GVMO6v30gUues8Ey/0gGeZ1UZRzN24II35DY 3KmWYucWC7TP3je2UM3gmT5XXzT5Jw80nP/01uxOavDP2at2K/raGHXZXspp1UHn7Tr7 ZMrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=mr6G0ILW; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o1-v6si33122325plb.220.2018.05.29.19.01.25; Tue, 29 May 2018 19:01:39 -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=@gmail.com header.s=20161025 header.b=mr6G0ILW; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755408AbeE3B7q (ORCPT + 99 others); Tue, 29 May 2018 21:59:46 -0400 Received: from mail-ot0-f194.google.com ([74.125.82.194]:37559 "EHLO mail-ot0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751180AbeE3B7m (ORCPT ); Tue, 29 May 2018 21:59:42 -0400 Received: by mail-ot0-f194.google.com with SMTP id 77-v6so19328934otd.4; Tue, 29 May 2018 18:59:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=Q/+r35UjzCD3/3JNoLCZg+73POxnL+Zl/G6ZiyVAZtw=; b=mr6G0ILWDEvrPyWC+uResb7qmN/PEQNXghAiO63gz9PWKmPILr4Y5I/e7eq5sJ3TOI rlOwoxGUfiKBsn5+B7AWiPB7UMJJo7VbWFd82WrQk3SDjGqNkj20nK5pwf2BT00S31N4 fO2V4CgASwjNJiVr6G1IazvLkgw4zYTYpxOu991H7c1mDhbudrUT+0C2g+bpq/VsGxeA gk+AYyuJI8ID9a2x5l7FEifxd4NG6UC8FWxD5t9LflPvbNZWLsDO84I5GiE2cuBgqjQu tftcE15sQ2SrSlH83+XCldiWVlbYu990gnCtrJfTkIyoYe51A/PbDLTv2Dd9tK6hN6OZ /org== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=Q/+r35UjzCD3/3JNoLCZg+73POxnL+Zl/G6ZiyVAZtw=; b=tJw4Yeh0PJckTMm8i/AYqFezNzkiSj5+fs0iu3Kb7i2FipOjwhHkxDOgkxzXLgmBV+ Qh4I58LjHd7AjBkyHzdxM8jXyoTDDDwS+atrqNKX2Y5nj0dDpCRY1zxqNT5iwwDh/eLO le8oVSS+xt9GcwdTt+dznKq7lv6VS+Hl0t+uk9AzfUD6FUAifQMJXK8DaMPfdQuSoRc4 0GUbfNxlzIqX2Tgu8ZqCgG/vZfWSjvt+nBktjMPyPM6kOu1JUjOmF/YQj3Xo3sGV4qZH VHauBZQrDq6DzOn2xt0I1M4pbolIzQE2EHA2qgvlg+9ivlwq7bcWFiWMFIfZZWUsYvwG oLJQ== X-Gm-Message-State: APt69E2a2sfibrP4R6m7HmoSi0h/ORhn0B8I60hiF8GqCWBP2kHhEabX FbnFei9TewylK3eDZK3JP66aTctmwMUtkwwg8S8= X-Received: by 2002:a9d:5b2a:: with SMTP id x39-v6mr473584oth.243.1527645582279; Tue, 29 May 2018 18:59:42 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:2451:0:0:0:0:0 with HTTP; Tue, 29 May 2018 18:59:41 -0700 (PDT) In-Reply-To: <1527574913-10561-1-git-send-email-nick.desaulniers@gmail.com> References: <1527574913-10561-1-git-send-email-nick.desaulniers@gmail.com> From: Nick Desaulniers Date: Tue, 29 May 2018 18:59:41 -0700 Message-ID: Subject: Re: [PATCH] ext4: prefer strlcpy to strncpy To: "Theodore Ts'o" , adilger.kernel@dilger.ca Cc: Nick Desaulniers , linux-ext4@vger.kernel.org, Linux Kernel Mailing List , ebiggers@google.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 28, 2018 at 11:21 PM, Nick Desaulniers wrote: > Fixes a stringop-truncation warning from gcc-8. > > Signed-off-by: Nick Desaulniers > --- > fs/ext4/super.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/fs/ext4/super.c b/fs/ext4/super.c > index eb104e8..d47c85f 100644 > --- a/fs/ext4/super.c > +++ b/fs/ext4/super.c > @@ -323,11 +323,11 @@ static void __save_error_info(struct super_block *sb, const char *func, > return; > es->s_state |= cpu_to_le16(EXT4_ERROR_FS); > es->s_last_error_time = cpu_to_le32(get_seconds()); > - strncpy(es->s_last_error_func, func, sizeof(es->s_last_error_func)); > + strlcpy(es->s_last_error_func, func, sizeof(es->s_last_error_func)); > es->s_last_error_line = cpu_to_le32(line); > if (!es->s_first_error_time) { > es->s_first_error_time = es->s_last_error_time; > - strncpy(es->s_first_error_func, func, > + strlcpy(es->s_first_error_func, func, > sizeof(es->s_first_error_func)); > es->s_first_error_line = cpu_to_le32(line); > es->s_first_error_ino = es->s_last_error_ino; > -- > 2.7.4 > Eric points out this will leave the rest of dest uninitialized if size is less than length of src.