Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3031714imm; Mon, 28 May 2018 22:58:05 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqoF68uJ25A4AAdgYOYAaLx5iU2LaFlwz7TyoxaQZLEPuVpslvRsD9NJRV9qAuAekvEOoOS X-Received: by 2002:a63:7741:: with SMTP id s62-v6mr12928600pgc.103.1527573485381; Mon, 28 May 2018 22:58:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527573485; cv=none; d=google.com; s=arc-20160816; b=NlJ6rt5CfKIzGeQ/b/Y7lpsKqWKVoMPQ0gZ3+XS/qVXL6uGiepNzQwNUIpnIvceF9w INUxZ8ogvAYob/u5OeiBQAHgjGWUewIsEC1ur5xKiUAUhXOW8fXgGjvT7GNIHDjz+oTg xpebzE80S7971lhQoYicZ6CBpBjk9F9X8ljgdLAnCXyYHRvVyEdZ9lWcAhvB1FsWuJIf TG1EN6ic99kZrNWOEJdH/QubhBzR3XgyISeBs3r4yXkf0dG4OHL4iahdIaMdVXud2/+3 3LsNL8uVs1IiIEGpTtxXhSjJ9yMmlHQUdAUF1aB2mVN3OpHz8G09XA48BosiujjRNaLG fIdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=W5LZmRA9+x+mV/R78W/SWXvRALqjpbCXvUJd3CDwyzU=; b=pCUaLfDuskCy/FdW/QH1CntHYFFr89PZEnKyO4AoTOefOFtQsbl3SrSMAXrRUVyFO0 8PQDFqqD3qeszH1USDNIX6VcuoquwU9E1Fzp3RoFoPW3/nKbnUuBITeDsMcvFTSbUQTM x2jC8NtNNWsfEN/HytdTBM6N+XvYLuRRQsC7wCy3KwNBTHkIn1GLpdgY0jOQbRypICyo sksPTD88ctEFW3YoRJdHNRi77Tmki8b0my34zk8TvRojGviCH6IKiXh6biN3ghWTEKi3 EAlDRhXO9j8S/nUzV4NDng2HQDd7wtFLeY84n4LgkNxJcvzbzeS/YeMI7vFMO+3lQcBc X2VQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ihplxwmR; 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 v64-v6si4789835pfj.292.2018.05.28.22.57.51; Mon, 28 May 2018 22:58:05 -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=ihplxwmR; 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 S1754440AbeE2F50 (ORCPT + 99 others); Tue, 29 May 2018 01:57:26 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:35455 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751852AbeE2F5Y (ORCPT ); Tue, 29 May 2018 01:57:24 -0400 Received: by mail-pl0-f67.google.com with SMTP id i5-v6so8312836plt.2 for ; Mon, 28 May 2018 22:57:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=W5LZmRA9+x+mV/R78W/SWXvRALqjpbCXvUJd3CDwyzU=; b=ihplxwmRhS+fJACjU+KVGl8DsTmSdswy1fT+WzCL3+wx1lqDkTbIJkpVM1F5HjyIIf GOo7fveqLcp8iTaYQ3KTuI2IX4OIZ23a5aXR2+pao2PDjhNnqF0TYE/BI0TlKNiUIBmX JSl9G6EzGCSycd4jR5P58UA+RyUMahUH1HgpSUalcrHJ2fsTu8eZRqwHnp8di7PKWpHy ci/AuaD470ckJMM32Em0IIN4bOb88g1YCCaehEH1/EYbEjpFxgbM/lFrdRJQZmlnZoJ2 mN1bxME3L5cImkzDB+0fryVKGGtQgwkxK6RUZ1Qqq8dLhPRFEDwV1S2wDk18LgheBVJa b0eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=W5LZmRA9+x+mV/R78W/SWXvRALqjpbCXvUJd3CDwyzU=; b=Emi4r9J3Xldasd6GP6orA7gZ26ceCXRw7wUZ/zBmlrFUR7kHR/TXjD/65l+Dh6NaRK CPe84tZ7lYB5ILBb1DOSBeMztwcxjg9g+CODV+tSrtJKgAtPfXLoiPprTymkv2CD6Asp sVu2v0SHHco8LrVDmZfzggOr5crHekbId4njxGOFLjEflnkxn0FClItCxZv9tDP2ZhqQ b9mPVt+lFa/UaNYZ3/aMO7Zd4bBbQAeikM/UBcDZXU0MWtOAoyR+PB1DIEdwfSEdtavm iEBoZECSEfVtrV5gLvwOYPrTcMCuF+VK8fbeQSw3WbN0sP9RWcMhOdPEtu0CD/0VPpvX lc6w== X-Gm-Message-State: ALKqPweaW7mRxRP1WlwNZC25xlzuu0e80RXl7LOdsv4FcMAK60m4y4sG nPPrs4Qckz9hfODHJzTjF18= X-Received: by 2002:a17:902:a512:: with SMTP id s18-v6mr16198900plq.223.1527573443499; Mon, 28 May 2018 22:57:23 -0700 (PDT) Received: from localhost.localdomain (c-24-6-183-110.hsd1.ca.comcast.net. [24.6.183.110]) by smtp.googlemail.com with ESMTPSA id h130-v6sm89088984pfc.98.2018.05.28.22.57.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 May 2018 22:57:22 -0700 (PDT) From: Nick Desaulniers To: jason.wessel@windriver.com, daniel.thompson@linaro.org Cc: Nick Desaulniers , Arnd Bergmann , Randy Dunlap , Baolin Wang , "Eric W. Biederman" , kgdb-bugreport@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [PATCH] kdb: prefer strlcpy to strncpy Date: Mon, 28 May 2018 22:57:04 -0700 Message-Id: <1527573427-16569-1-git-send-email-nick.desaulniers@gmail.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fixes stringop-truncation and stringop-overflow warnings from gcc-8. Signed-off-by: Nick Desaulniers --- kernel/debug/kdb/kdb_io.c | 2 +- kernel/debug/kdb/kdb_main.c | 4 ++-- kernel/debug/kdb/kdb_support.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c index ed5d349..b5dfff1 100644 --- a/kernel/debug/kdb/kdb_io.c +++ b/kernel/debug/kdb/kdb_io.c @@ -443,7 +443,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); diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c index e405677..c30a0d8 100644 --- a/kernel/debug/kdb/kdb_main.c +++ b/kernel/debug/kdb/kdb_main.c @@ -1103,12 +1103,12 @@ static int handle_ctrl_cmd(char *cmd) case CTRL_P: if (cmdptr != cmd_tail) cmdptr = (cmdptr-1) % KDB_CMD_HISTORY_COUNT; - strncpy(cmd_cur, cmd_hist[cmdptr], CMD_BUFLEN); + strlcpy(cmd_cur, cmd_hist[cmdptr], CMD_BUFLEN); return 1; case CTRL_N: if (cmdptr != cmd_head) cmdptr = (cmdptr+1) % KDB_CMD_HISTORY_COUNT; - strncpy(cmd_cur, cmd_hist[cmdptr], CMD_BUFLEN); + strlcpy(cmd_cur, cmd_hist[cmdptr], CMD_BUFLEN); return 1; } return 0; diff --git a/kernel/debug/kdb/kdb_support.c b/kernel/debug/kdb/kdb_support.c index 990b3cc..dcfbf8f 100644 --- a/kernel/debug/kdb/kdb_support.c +++ b/kernel/debug/kdb/kdb_support.c @@ -236,7 +236,7 @@ int kallsyms_symbol_next(char *prefix_name, int flag) while ((name = kdb_walk_kallsyms(&pos))) { if (strncmp(name, prefix_name, prefix_len) == 0) { - strncpy(prefix_name, name, strlen(name)+1); + strlcpy(prefix_name, name, prefix_len); return 1; } } -- 2.7.4