Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4554088ybi; Tue, 30 Jul 2019 04:08:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqx4aOR8M5Nd5DHOZOtYL7vvNja6lTh3LZwCNT79zSjvl75Yt7Xqvn4QXQEY9f/0UVxfwXH5 X-Received: by 2002:a65:60d3:: with SMTP id r19mr83517899pgv.91.1564484917299; Tue, 30 Jul 2019 04:08:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564484917; cv=none; d=google.com; s=arc-20160816; b=V2R6r6/e8vnmOL0ijOkTYW8BwULjhvnUzigr2GwihB8WAH26TWo1oeYoLfIvQTvXD/ CTPQAvaFEu8TGqjlA6ZTOha1RKsMfAfQEYKnnaEIu1l7PRC16w9ZktdY/QTDpMlNGhUA 5jlqaexiDE2LwChzvxNfwCTdNTT0TieGJ58KgbisgtiGvpDJwSncyySGVk9eZ+UkYuRG 3dIWl0voI9c53y80f4dJ+DRmre3vShQbjZ7ASZ4nklzpgrZq4Rty7H4wU7nLkDB0aym3 /CN8Sd+mY9cdHJsuzh0OhVHRsEjVY5ZvdiUtYkiqCgEPCzAS+SE/8ucI8ceLFbGpoZ8U qGHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:content-transfer-encoding:mime-version :message-id:date:subject:cc:from:dkim-signature; bh=A6QIpcbQwJEsmdV9za/A3e+Q7a5KK84Ntv3twcinB6Q=; b=MZcVOq/llT3yHf1TBv5/G+orMMlVhMAk3UuSlXgOBvLFhXWKr3LCwnIljV2DOxz/t+ Jc6kUYisTs45HXTdnBj1NxemxnH3OU5WIbS01f0gkR0FJnYvfwq8xj/k+mDEXr/bd0Pu 7YbDkG0DR4CzHAH9/QrEtTMbQbS23gUwN3+Z2RVDsoBkFPI0Hp+8ks0GZur5gWC/Tqoi IRE6AH+6NOirf2269uF/vs4q9Rw+amHoEkz1154FpQjwBEdr0Jh3IviwMwXyNjmMSZ/M TGMzIxTWLr5zk2ew3e6pHf6NrQJdaMuI5TEM4n3tR4HWuAZqR0+EdkO71QsECKKFCuhS Nzeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=HOtAPxnk; 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=fail (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 r190si28686140pfr.102.2019.07.30.04.08.22; Tue, 30 Jul 2019 04:08:37 -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=fail header.i=@gmail.com header.s=20161025 header.b=HOtAPxnk; 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=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730952AbfG3Ik0 (ORCPT + 99 others); Tue, 30 Jul 2019 04:40:26 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:34458 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728354AbfG3Ik0 (ORCPT ); Tue, 30 Jul 2019 04:40:26 -0400 Received: by mail-pg1-f193.google.com with SMTP id n9so23462549pgc.1 for ; Tue, 30 Jul 2019 01:40:25 -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:mime-version :content-transfer-encoding; bh=A6QIpcbQwJEsmdV9za/A3e+Q7a5KK84Ntv3twcinB6Q=; b=HOtAPxnkYxXPOgY+lRaNs+9k6CiAz/8Or0Rrz46RZ1Qiv+hUxY9scbqat3x6a+rhaF Tv8bZid99hhHpb+EpmHVuBNFXRHOb96f9TX7TZe65twC5I6dfnTM+5C0SNBVv3grvgY7 /V0NqY/dwbrcIN9P8sQ4PJYh0Po7H16BJiSJ1ZRZf8MoSUKFu0lJFpZwQspSEIYaj9e9 C4c6DG+VYpPYbu1hfHT/WcALz1SkylFMFTUgRE3ruRxp+TyVhMiM2VsEn3FeiU3/0YD2 Z0jnfcHIPdubjm6LQswnzokSpBLQ8Ys/yv+E8fM19D1yxo914KN/gtaUdT7pdl+dAlgT IVqg== 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:mime-version :content-transfer-encoding; bh=A6QIpcbQwJEsmdV9za/A3e+Q7a5KK84Ntv3twcinB6Q=; b=Q3H1zc187KMlECbaUYbTNBc0djjjuuNcUV+d9JY4AjWkthU6ovTFcpBKtuAGmY6kL9 5SOxc/PtWu6++58IjDoIlq/x/uoknit3H8yEjIcd4jSkgnJqejnF+EvbI/9B9LPzc1yR y3kTJXBBgHjasjPVeISAlHeQWrlXnxnbe+IWMCAeTHzgA1/Z/rwXZjpQpH8KaHyiMELo m7B6vh8BvPUszGelGEpZhLQqEGoWhJ1OWegsPjjgyR7pTzxkeUdds92geIBrwaYXzKkI f2bZKYyzleEl6WvT9Vmw36wXC7B0XwD8Yr/uvxg2HfuyPOKrrDXX5ImldjzepGbSgd8B +eQA== X-Gm-Message-State: APjAAAXY9ACHDlmNeoAxzsj9djUoJHvVfX+wvbo/v5CjaVjyhosYC7xl sXKXO2Q7/FFJSz4qSUvWH3jNRLHJw3Y= X-Received: by 2002:a17:90a:a407:: with SMTP id y7mr116140568pjp.97.1564476025643; Tue, 30 Jul 2019 01:40:25 -0700 (PDT) Received: from suzukaze.ipads-lab.se.sjtu.edu.cn ([89.31.126.54]) by smtp.gmail.com with ESMTPSA id x65sm63854576pfd.139.2019.07.30.01.40.23 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 30 Jul 2019 01:40:24 -0700 (PDT) From: Chuhong Yuan Cc: Corentin Labbe , Herbert Xu , linux-kernel@vger.kernel.org, Chuhong Yuan Subject: [PATCH] crypto: tool: getstat: Fix unterminated strncpy Date: Tue, 30 Jul 2019 16:40:18 +0800 Message-Id: <20190730084018.26374-1-hslester96@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org strncpy(dest, src, strlen(src)) leads to unterminated dest, which is dangerous. Fix it by using strscpy. Signed-off-by: Chuhong Yuan --- tools/crypto/getstat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/crypto/getstat.c b/tools/crypto/getstat.c index 9e8ff76420fa..554ba08d9652 100644 --- a/tools/crypto/getstat.c +++ b/tools/crypto/getstat.c @@ -41,7 +41,7 @@ static int get_stat(const char *drivername) req.n.nlmsg_type = CRYPTO_MSG_GETSTAT; req.n.nlmsg_seq = time(NULL); - strncpy(req.cru.cru_driver_name, drivername, strlen(drivername)); + strscpy(req.cru.cru_driver_name, drivername, strlen(drivername) + 1); sd = socket(AF_NETLINK, SOCK_RAW, NETLINK_CRYPTO); if (sd < 0) { -- 2.20.1