Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4745755yba; Wed, 8 May 2019 01:57:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqw1bMP+44i4EiwE8HBVjcxTRD2B0FLt/1sVFsHlx67YdD7rsvXw5m3MD7iUPnY0WYhn7I+R X-Received: by 2002:a17:902:aa85:: with SMTP id d5mr2181033plr.245.1557305864443; Wed, 08 May 2019 01:57:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557305864; cv=none; d=google.com; s=arc-20160816; b=PWnhsxymd5z9i6OpUnZhcaw4ocfTWn6mXQs/kFXCTz/EZ0dbxyJFvJ4JeR7w5BrFFd WskQEEGow8Xh0MxT31TdBK3RJ6L7e5APvdMcHiff2BLqReXlL4ulOIbrvgDPQZZ7LY9U jC2BWziZmtrVPLFVFEfhqmgylQj33fgOJIwa/2tlTtiAv+zJT6rz7ycHsyywD/7fOnvO X6EzLonqo7tqiNqNvExMMTgwvkYssGfa4FFW9KnzliSMpp8rhQFxDkG+B5ZV02C5CZnx uHz9vvwT58e31KIXqkmRBCqAvvF2U1MC/M6mBp0O4fAB2rFO61P+IHs0gGNw7T93gI2C Irqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=GAXYVm9NcX/2LS+PAeOz79lHGPmC519ptueWLbeJo8k=; b=o07axyYa5/quoZwvqA/2s/K5grXKfIwWPqfXnAee1WP/MB3ZVh4RHHypWABuel3k3u TE+IVnffWhGU5zyo+6JG17Sc8eQdfzB46Y0C24Th3qDixFwkOfDc+eRiFHVPMU1sdFRA ekkWR+LugglCI79DOFydoISQLa3K/Nb8SeCEGzn9qOHp7XVZApQem8IcCOXmER6rN9Pt ScAQi/C9EJBlOO2EdcaYwa8ZnAxc2r1zx0WtAzivtkKvJmRkjZvTkLkVYYy7espUF5CF m26/RflXFBDGciIIScf0VE3P8Dsw9b/1njI31CeCXqbpeRExJ+UMOwxorjp+OZW+uEZq u7kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oXeyXO6C; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k11si22065530pfa.163.2019.05.08.01.57.28; Wed, 08 May 2019 01:57:44 -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=@linaro.org header.s=google header.b=oXeyXO6C; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726902AbfEHIQp (ORCPT + 99 others); Wed, 8 May 2019 04:16:45 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:37862 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725842AbfEHIQp (ORCPT ); Wed, 8 May 2019 04:16:45 -0400 Received: by mail-wr1-f65.google.com with SMTP id a12so15840086wrn.4 for ; Wed, 08 May 2019 01:16:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=GAXYVm9NcX/2LS+PAeOz79lHGPmC519ptueWLbeJo8k=; b=oXeyXO6C0pw6WvX5xZqKPgGsXKCY0G9zfoXSWEV79JmfIgrUqcvThF3c1YIifzZWLG kx1W7KwZYeRCMKXKrM0K09z2V3abI581w9sZsEWhfIe14Bn9LTQT+MbvqpYNctqZQQ8n mlTc+hcrWbSh7g5ECWlxDYTcM2tbaELh7qwtazUS4EW+WxxyVL65gaLOVogQ+75hxVtp jQql/ObUJjEsKllPLxEwhc6R+s41C43RWWcjxDKsu6x8zZJd1pVmbddxfNCPF0/wbSyG dSYgZyROGY5LAcxiJLbpVoF5AHTWJiBXzrcdlr5NUki/Et8NFNKpSW9opSp1vcUWp1sO hlPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=GAXYVm9NcX/2LS+PAeOz79lHGPmC519ptueWLbeJo8k=; b=Xgj9xm4JEB7La0p6B4knLDeOC7PzziOOI7cVxTynj/GjDuty5r+RKcpMPa2xvnuhLu v3Lwntfd7HwweZ4J441jvP/o/G4JrUFfVYO+N/IHRes/bchEbvUvut36QKbNRfC/TfTx FKxSo6Zcl7UHHcYerANVHrm82GzLSllHTOIm1c/zY5ztzQgAKYJZtMRs+NbQ+XY0zMqB uZZzfeRTpqSEBiwUrEDVVN4IUFYK2FPdlucvH2rBWarlpwkZtigwTihM5wSWycbom1v/ qqdX0RJH3cSyvn42OrwGy5FVxpBuwgXme3OB7Uwt4SQ2YxTUur6eKOLWuIRzI1soIIcm 2SDA== X-Gm-Message-State: APjAAAWN6oYYZYzzzTXFZwcxr3sf4DFtiPr9FkGttFC4rSfaOUnfim/w FZc1CQy0k3jzsc/QqtaxVTHVeQ== X-Received: by 2002:a5d:4f88:: with SMTP id d8mr10862408wru.34.1557303403211; Wed, 08 May 2019 01:16:43 -0700 (PDT) Received: from holly.lan (cpc141214-aztw34-2-0-cust773.18-1.cable.virginm.net. [86.9.19.6]) by smtp.gmail.com with ESMTPSA id m17sm3556067wmi.27.2019.05.08.01.16.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 08 May 2019 01:16:42 -0700 (PDT) Date: Wed, 8 May 2019 09:16:40 +0100 From: Daniel Thompson To: Wenlin Kang Cc: jason.wessel@windriver.com, prarit@redhat.com, kgdb-bugreport@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: Re: [PATCH] kdb: Fix bound check compiler warning Message-ID: <20190508081640.tvtnazr4tf5jijh7@holly.lan> References: <1557280359-202637-1-git-send-email-wenlin.kang@windriver.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1557280359-202637-1-git-send-email-wenlin.kang@windriver.com> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 08, 2019 at 09:52:39AM +0800, Wenlin Kang wrote: > The strncpy() function may leave the destination string buffer > unterminated, better use strlcpy() instead. > > This fixes the following warning with gcc 8.2: > > kernel/debug/kdb/kdb_io.c: In function 'kdb_getstr': > kernel/debug/kdb/kdb_io.c:449:3: warning: 'strncpy' specified bound 256 equals destination size [-Wstringop-truncation] > strncpy(kdb_prompt_str, prompt, CMD_BUFLEN); > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > Signed-off-by: Wenlin Kang > --- > kernel/debug/kdb/kdb_io.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c > index 6a4b414..7fd4513 100644 > --- a/kernel/debug/kdb/kdb_io.c > +++ b/kernel/debug/kdb/kdb_io.c > @@ -446,7 +446,7 @@ static char *kdb_read(char *buffer, size_t bufsize) > char *kdb_getstr(char *buffer, size_t bufsize, const char *prompt) > { > if (prompt && kdb_prompt_str != prompt) > - strncpy(kdb_prompt_str, prompt, CMD_BUFLEN); > + strlcpy(kdb_prompt_str, prompt, CMD_BUFLEN); Shouldn't that be strscpy? Daniel. > kdb_printf(kdb_prompt_str); > kdb_nextline = 1; /* Prompt and input resets line number */ > return kdb_read(buffer, bufsize); > -- > 1.9.1 >