Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2008826imu; Fri, 14 Dec 2018 04:26:22 -0800 (PST) X-Google-Smtp-Source: AFSGD/Uw0RVeJ9qzq8oG+OH9u5lx8Vps/YcQORicwyz/WtTE44+Em6e+cSBdNkp2XWvIbKDENWMz X-Received: by 2002:a62:13c3:: with SMTP id 64mr2634168pft.93.1544790382049; Fri, 14 Dec 2018 04:26:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544790382; cv=none; d=google.com; s=arc-20160816; b=bYRcw8V5fFxtaaZ7X7X9uZL50uYKhS5XIgK/FrMVsGv5rcSRYq+f1zaLKrVthZAEF4 MHDEEGWM0TJObLCnMfjKuT/QWefjq7cL0mcRAttUhoZWboY8rIlmlVAVHy8cpq3oRSk4 A1WBLK3u/3dSKxmzZvcxlhQYyp+UdoCTMlLQ5hQD4MDsQE/oFqqqquobEYNvc+1kSJEB U3AkWd8KjGkgNDNbADxVyABE6rvsIJv5WixuPJ3ApNJWsdiskQZkGx3ejbrLY2BWXxNI quyfgCi1NJfQbp+PrNfko2q98fK1Y1jVShODUV0TjWSEp2l5oZYWWonttlrmaKYXc/n6 7IZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=85GJmGZ9bZbGq9srAZ/OZfgXIvH+Ai3YKmyggdhcfW0=; b=VKWdKFCdluWpGSrhqcSYfy1KrGprqSe/x5Cd+kTVzMFfDA23dXZWhrTHv1szD5xWc8 zNhEUW74U2ou2ZfbSQ+TB5ZQoRHKKDmNzPZgJSMTpqoACm9r3yippjvUqaG6V1u99NjI f5Ya3R/Q3m45uH8Q+bbLFx5r1IovPaAUW3SwK0kKmueNqADhHhjmZMYtnlEpyywUdmyG vpxuuuqWBXOOqeXgOQuOpPvIylIggfa2bOpZofIGnHkeKDrTiO2T90MI0inp4DXW59TR H03n6qooImOFVs5mL2b59999pv9eIcgw7q2J3VBy+cHDJUPKEjFpQWRpnJpakKkwUbDc IUQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=V0y8IloL; 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 g12si1727966pll.428.2018.12.14.04.26.07; Fri, 14 Dec 2018 04:26:22 -0800 (PST) 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=@kernel.org header.s=default header.b=V0y8IloL; 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 S1731277AbeLNMNK (ORCPT + 99 others); Fri, 14 Dec 2018 07:13:10 -0500 Received: from mail.kernel.org ([198.145.29.99]:60626 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732064AbeLNMNI (ORCPT ); Fri, 14 Dec 2018 07:13:08 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 16E90214D9; Fri, 14 Dec 2018 12:13:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544789587; bh=26afetUyxQS4fiu8eDnRQoS2U3xGw4AvWuASA2NTMTc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V0y8IloLlITZs8w4/92Xp/my27336ggJfQ/tRQoV93gvRDoc7J7eGn93WJi5OVJDB GfQVPRNZ8tUSMwgi7GqzWC6viy/4y8SWe88hVVe+D3MbxVEBF8bT4l8khcPfay+Ryu uJZOBPyaL2d9tEX2EvPJp7WRXfNoMN2OTxYcRg9c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Guenter Roeck , Samuel Thibault Subject: [PATCH 4.9 51/51] staging: speakup: Replace strncpy with memcpy Date: Fri, 14 Dec 2018 13:00:53 +0100 Message-Id: <20181214115717.564072777@linuxfoundation.org> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20181214115713.244259772@linuxfoundation.org> References: <20181214115713.244259772@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Guenter Roeck commit fd29edc7232bc19f969e8f463138afc5472b3d5f upstream. gcc 8.1.0 generates the following warnings. drivers/staging/speakup/kobjects.c: In function 'punc_store': drivers/staging/speakup/kobjects.c:522:2: warning: 'strncpy' output truncated before terminating nul copying as many bytes from a string as its length drivers/staging/speakup/kobjects.c:504:6: note: length computed here drivers/staging/speakup/kobjects.c: In function 'synth_store': drivers/staging/speakup/kobjects.c:391:2: warning: 'strncpy' output truncated before terminating nul copying as many bytes from a string as its length drivers/staging/speakup/kobjects.c:388:8: note: length computed here Using strncpy() is indeed less than perfect since the length of data to be copied has already been determined with strlen(). Replace strncpy() with memcpy() to address the warning and optimize the code a little. Signed-off-by: Guenter Roeck Reviewed-by: Samuel Thibault Signed-off-by: Greg Kroah-Hartman Signed-off-by: Greg Kroah-Hartman --- drivers/staging/speakup/kobjects.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/staging/speakup/kobjects.c +++ b/drivers/staging/speakup/kobjects.c @@ -387,7 +387,7 @@ static ssize_t synth_store(struct kobjec len = strlen(buf); if (len < 2 || len > 9) return -EINVAL; - strncpy(new_synth_name, buf, len); + memcpy(new_synth_name, buf, len); if (new_synth_name[len - 1] == '\n') len--; new_synth_name[len] = '\0'; @@ -517,7 +517,7 @@ static ssize_t punc_store(struct kobject return -EINVAL; } - strncpy(punc_buf, buf, x); + memcpy(punc_buf, buf, x); while (x && punc_buf[x - 1] == '\n') x--;