Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3050253pxk; Mon, 7 Sep 2020 01:26:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz/VY2n0G9/QE2GegPdplOrVO41AsQJknr2745odJYrsywpYti7DAXzvQlK4+/cEFAIVIcU X-Received: by 2002:a17:906:3e0c:: with SMTP id k12mr19594316eji.189.1599467173985; Mon, 07 Sep 2020 01:26:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599467173; cv=none; d=google.com; s=arc-20160816; b=JQ4hsTRzEZ0GhbIYN6+migp803ERtKmgbLU0WmDzlgbNdCwOlx2+xe46nfUvkYSjt9 RACCL18XDVkV3PV2dphuakRr09XtiNZOblFkLxPWGJ+dbJuayYou0ibS7HAQEo4Gafr4 IAnnDnnKckDZvCNBSIwuSguSTZIqaF+om1CKkJqB0C+hZJkGJgVcuwQQnGejLF6/G4qV Br/x2LwtlutrwQLrh8Aly3vd2S5XtkE5DmdNzNnT1rXeakdTTuQJw0dZTEhvc3sThfFx dtRC35kzXZK4vhPy7ytIJppn01h8mUU6c5RsU7KxViPy4Va7wx6xUBVUv5kyw5kWO5lb PuPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=YZ6MWL9B0LACn1bSUfeQElCJahOsJDB6YjJu5F33XRI=; b=lU5nGqZCJlYGxMsKdQRBKF+7JS67kFSfrTmyEXD5lMK70y9VC+s65SGNQBcFko4DYL IK0TAOtUAjVOWKQ1DrN+sXYbMc1zLg8uuk0AMFpzpXHVxVMkPbTWfRcDTpB9RAs6g57R 6RN90nqCjOLwdzlJnDEoy1ft/LyTrfffWBd86H+iFi6vCTibyYsFubwT/LfDXBRU6pTT oUL9KiS/CbFhvh1fuyAZ4w/6HY0v1f/Kp0gKrqdB4djBvd1XGs/GzYx/FF1xeW7ILVgK 8qQIhsUTESgFwrd8mAu03o9+jWx1MYCXMekPQ0yj5Ve5oSoV4bnjE4Lk0wsWoZNREB0F TQDQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g17si8958647edw.332.2020.09.07.01.25.50; Mon, 07 Sep 2020 01:26:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728168AbgIGIZT (ORCPT + 99 others); Mon, 7 Sep 2020 04:25:19 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:10784 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728004AbgIGIYm (ORCPT ); Mon, 7 Sep 2020 04:24:42 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id F225D5B34AAA300B1629; Mon, 7 Sep 2020 16:24:34 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.487.0; Mon, 7 Sep 2020 16:24:24 +0800 From: Yang Shen To: , CC: , , , Subject: [PATCH v2 04/10] crypto: hisilicon/zip - replace 'sprintf' with 'scnprintf' Date: Mon, 7 Sep 2020 16:21:56 +0800 Message-ID: <1599466922-10323-5-git-send-email-shenyang39@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1599466922-10323-1-git-send-email-shenyang39@huawei.com> References: <1599466922-10323-1-git-send-email-shenyang39@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Replace 'sprintf' with 'scnprintf' to avoid overrun. Signed-off-by: Yang Shen Reviewed-by: Zhou Wang --- drivers/crypto/hisilicon/zip/zip_main.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/crypto/hisilicon/zip/zip_main.c b/drivers/crypto/hisilicon/zip/zip_main.c index df1a16f..dd2c326 100644 --- a/drivers/crypto/hisilicon/zip/zip_main.c +++ b/drivers/crypto/hisilicon/zip/zip_main.c @@ -428,7 +428,7 @@ static ssize_t hisi_zip_ctrl_debug_read(struct file *filp, char __user *buf, return -EINVAL; } spin_unlock_irq(&file->lock); - ret = sprintf(tbuf, "%u\n", val); + ret = scnprintf(tbuf, sizeof(tbuf), "%u\n", val); return simple_read_from_buffer(buf, count, pos, tbuf, ret); } @@ -518,9 +518,10 @@ static int hisi_zip_core_debug_init(struct hisi_qm *qm) for (i = 0; i < HZIP_CORE_NUM; i++) { if (i < HZIP_COMP_CORE_NUM) - sprintf(buf, "comp_core%d", i); + scnprintf(buf, sizeof(buf), "comp_core%d", i); else - sprintf(buf, "decomp_core%d", i - HZIP_COMP_CORE_NUM); + scnprintf(buf, sizeof(buf), "decomp_core%d", + i - HZIP_COMP_CORE_NUM); regset = devm_kzalloc(dev, sizeof(*regset), GFP_KERNEL); if (!regset) -- 2.7.4