From: Thorsten Blum Date: Tue, 24 Mar 2026 11:27:05 +0000 (+0100) Subject: crypto: hifn_795x - Replace snprintf("%s") with strscpy X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d7f3162ff802b5c39e3c449be8bccd297a4d7267;p=thirdparty%2Flinux.git crypto: hifn_795x - Replace snprintf("%s") with strscpy Replace snprintf("%s", ...) with the faster and more direct strscpy(). Check if the return value is less than 0 to detect string truncation. Signed-off-by: Thorsten Blum Signed-off-by: Herbert Xu --- diff --git a/drivers/crypto/hifn_795x.c b/drivers/crypto/hifn_795x.c index a897541f897b3..2da0894f31fd8 100644 --- a/drivers/crypto/hifn_795x.c +++ b/drivers/crypto/hifn_795x.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -2256,8 +2257,7 @@ static int hifn_alg_alloc(struct hifn_device *dev, const struct hifn_alg_templat alg->alg.init = hifn_init_tfm; err = -EINVAL; - if (snprintf(alg->alg.base.cra_name, CRYPTO_MAX_ALG_NAME, - "%s", t->name) >= CRYPTO_MAX_ALG_NAME) + if (strscpy(alg->alg.base.cra_name, t->name) < 0) goto out_free_alg; if (snprintf(alg->alg.base.cra_driver_name, CRYPTO_MAX_ALG_NAME, "%s-%s", t->drv_name, dev->name) >= CRYPTO_MAX_ALG_NAME) @@ -2367,7 +2367,7 @@ static int hifn_probe(struct pci_dev *pdev, const struct pci_device_id *id) INIT_LIST_HEAD(&dev->alg_list); - snprintf(dev->name, sizeof(dev->name), "%s", name); + strscpy(dev->name, name); spin_lock_init(&dev->lock); for (i = 0; i < 3; ++i) {