Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4934392yba; Mon, 13 May 2019 02:19:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqzUp5wFZx+autJvy1JSLvq1+jHgtrvlaJdRSidcrrnEn52Wldwdzz0tld6z0MCMCNEWPKm5 X-Received: by 2002:a17:902:4a:: with SMTP id 68mr29707316pla.235.1557739143708; Mon, 13 May 2019 02:19:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557739143; cv=none; d=google.com; s=arc-20160816; b=MpeVm3yaJVEW7pjCRMo19af6LkJG5f1eTwT4r6pBW2dVESF1+E9EuYuzbIsVUfFxua efrutWwnIiBP5/QXpxhCv/6yahMUIuukMGptI1xT8br1VznoeJiKnl31qWoWgRcLPziS k2dv+ap7bu5wlQJx/KQKJXkP36eOseluT33pJbPGEjDEWfQYvh8dHTtiudF1LiBoLZ5D 1ndhjp6FSZJuL1RYZT+CJPVqO1IEfLBOJsBnQfa81IemG04kvXuZQjAbDF2nxpNtURVr tHwzxDMuLxbnUbngWpTE4Y6Qcy6g9QPj4OeaRRJ8r5KA/5Jia3s52wAWRFu5SFgAXPJ4 R3Dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=jiLApC5JOtrm0lTTtxoL/EEzphqePom4uQh+Btlsg4E=; b=cYYuqOoDnDaM5EPldE+pYUonSWuSu9PLsAxSaZUsIuIJt8DuLIsm9tKAO/eS6ln14d UFFHBQHV1jFTrsTYGRk+KTWvAi6+yvAQ/eTvL/zoVziQdhcKkXhPC0o2WcnHlS/lEol9 EQh7TRaBcZY1xX6Kiuza69R+vIm8e0f5b3WY78bqnQa9YFl7bWD3anIgEGE3ZK+GMWOr m9fGxlSBk8eS/dKo/HUp7tylIsrmCpjn6XrLhxguGnKC38EtYsYZp9P87aFq2tgLFw+g QaZONYXSp2qvxOV3rn1Zevo25dBAFqo9H+fMgMLQg++LR5Dk8rWknw8ehZ93Z+c78KnE nCMQ== 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 b66si1028962plb.426.2019.05.13.02.18.47; Mon, 13 May 2019 02:19:03 -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 S1728834AbfEMJPM (ORCPT + 99 others); Mon, 13 May 2019 05:15:12 -0400 Received: from mail.windriver.com ([147.11.1.11]:41968 "EHLO mail.windriver.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728193AbfEMJPL (ORCPT ); Mon, 13 May 2019 05:15:11 -0400 Received: from ALA-HCA.corp.ad.wrs.com ([147.11.189.40]) by mail.windriver.com (8.15.2/8.15.1) with ESMTPS id x4D9EuMe005288 (version=TLSv1 cipher=AES128-SHA bits=128 verify=FAIL); Mon, 13 May 2019 02:14:56 -0700 (PDT) Received: from pek-lpggp2.wrs.com (128.224.153.75) by ALA-HCA.corp.ad.wrs.com (147.11.189.50) with Microsoft SMTP Server id 14.3.439.0; Mon, 13 May 2019 02:14:56 -0700 From: Wenlin Kang To: , , CC: , Subject: [PATCH v2] kdb: Fix bound check compiler warning Date: Mon, 13 May 2019 16:57:20 +0800 Message-ID: <1557737840-43258-1-git-send-email-wenlin.kang@windriver.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The strncpy() function may leave the destination string buffer unterminated, better use strscpy() 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..3a5184e 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); + strscpy(kdb_prompt_str, prompt, CMD_BUFLEN); kdb_printf(kdb_prompt_str); kdb_nextline = 1; /* Prompt and input resets line number */ return kdb_read(buffer, bufsize); -- 1.9.1