Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4454334yba; Tue, 7 May 2019 19:13:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqzB/AHiRV2P7vLVfZxytsTg9/6ot/5AEfMAgcU9KJXPzok6ApzngqvKOo5gxpmoSbGd7YSv X-Received: by 2002:a63:f54c:: with SMTP id e12mr2996726pgk.62.1557281619515; Tue, 07 May 2019 19:13:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557281619; cv=none; d=google.com; s=arc-20160816; b=QnmH1yGbKE4Q9AomwUX4zrstdX36cPrq1jBHBDD8HE32ZHe/33ZCZyyJRtVurZdCWe wDA0x738Uvc0zOLR4CU6p6KOCM9m86ErPv4VC+5JsAxSko2ASVqq9AcGROcUJEn47f3N lwNZH7P9ikSEJ2zUpPo3ItOiTrXc7SU2GXb0QjzIvor4Y+NetlwU9sYTpJeunSO0z2MV Ygw9Q5j1VYegD/VV/EwufNeqEngwxg0vFgbTLe5c8mxpnkGKR+OQHF+MUur5mVYg1F6s C45PSzVZZprwlOI6kpkbN14GuykGyHZz+TNR50XU8bxEOw4AGJ38KUOWdjOVuZ/Rap48 r5FA== 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=QGsRVc3/99GVHG/ZbFpTWRXq1PKrFnhfP2xrLtPINNk=; b=q36fIvNV6tKolXE9PkZda/hvtkzXZEI+Xj3uViMPqVHof1EIcODNkPm461cAh64t+y Slj0o3P0k//hSnH7kudLsTwxHzlcsCqGnxooZjqag2buX8FXAf63tmPt7HrSb6YK7nRy YZp+AzZK4fVOi9In+q4EQpLLUml6Jm1v7fSVBKcOJDpCt7RSB0Qm3Z40HcvcTOIaEggP VuWEf7MXTJJoziKCQ9OwON/xTGRJZJgmcneQkWAWjcn1+p6SQo30od9uF9a8Inl6fN2W n+hntJrj7HRRhvi8/jQVsUc2uhV41hYxvfQ+mj2nSIVSaWjx9fptNuZ8zfQXgcCDK/nL 1F2Q== 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 x12si14660975pgg.531.2019.05.07.19.13.23; Tue, 07 May 2019 19:13: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; 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 S1726527AbfEHCKe (ORCPT + 99 others); Tue, 7 May 2019 22:10:34 -0400 Received: from mail.windriver.com ([147.11.1.11]:34943 "EHLO mail.windriver.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726371AbfEHCKe (ORCPT ); Tue, 7 May 2019 22:10:34 -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 x482AFAE015100 (version=TLSv1 cipher=AES128-SHA bits=128 verify=FAIL); Tue, 7 May 2019 19:10:15 -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; Tue, 7 May 2019 19:10:14 -0700 From: Wenlin Kang To: , , CC: , Subject: [PATCH] kdb: Fix bound check compiler warning Date: Wed, 8 May 2019 09:52:39 +0800 Message-ID: <1557280359-202637-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 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); kdb_printf(kdb_prompt_str); kdb_nextline = 1; /* Prompt and input resets line number */ return kdb_read(buffer, bufsize); -- 1.9.1