From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf0-f45.google.com (mail-lf0-f45.google.com [209.85.215.45]) by dpdk.org (Postfix) with ESMTP id 1B1A99B6B for ; Wed, 11 Oct 2017 13:05:11 +0200 (CEST) Received: by mail-lf0-f45.google.com with SMTP id l23so1610502lfk.10 for ; Wed, 11 Oct 2017 04:05:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=a80aWE1hvh0PJUpJ/vwLZxyuF/wkcXjyR9t/OMcN1a8=; b=1ltFOWTjBCqeiB4Y3AR9I6FU/GjsNXKRkqKVwhVJDV57ID5CaZr5SqPkX63vXbz4bX K8Kg76f2jFyevJYz45VUp/7GNuNcLHtQInR+VxoxSUaQ5fuesDKItJQtrwlqsDdzYOvd 4dVijVnsuTW3q2CKfJjRvx9xqs8jWyDRGGiW6+isJvQZGXu0ussduNzVpaDodpn3Ma/S DknRi8hYzG4sjnqxU12ye/oI5z23V4FgXImvh/n+VbuBVoYiMJCNnG/EJ2yZLvH7g5HA 185OZtpOnE9mG2MzPMGoE2njjyMxxt6SjL/SbHfQelhWWfeBEX0XdCFkZ+n//Z+D3M9p YtDw== 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:in-reply-to :references; bh=a80aWE1hvh0PJUpJ/vwLZxyuF/wkcXjyR9t/OMcN1a8=; b=Wyei/+SyKs0FS+GYfaYgFjZMr6WDBmblzL2BMuTA1CoYuALAt0CyHHT4F+Lv7o41nK O9YYl0nEsSNrfN7dgLsprRysuTpvU0ffOi2E1ldrNoy0ITUCPor8w6xb1GPSkSF0VHTj 9eRjdazIPxELI/DTiRePwZq6Y3ItFhq6z8iYqG0C1FZZYPJGl2BXT2lz6deknEXWY6gc BxlPjsgVi6/W/vEPA/1RK7lffc4YF0kDWhuxH3a2PYVb5jcrv3VKIasBOTzf/e5s8vQU K3wD3g+5QMyDucuK2DpkAPiYN5ER06V9GRWGyzgQf2aBZF/V7BDeb/SfkJIXlZGk0pDY 1T6Q== X-Gm-Message-State: AMCzsaXKBq0PMHNYZfI3SRMHggn4QcBJLFSdO6AaStBHOHYeeXJw1ZL3 12ObWLADV87JpBnu8szkW8HCxzJ9Wgc= X-Google-Smtp-Source: AOwi7QCC0rBr4DI+yTQLaWe6h5yC8uhyFEIc/EG9Us3cI4CVRpnLKrCCCjt/+vyjR9ICGElW7skjJA== X-Received: by 10.46.66.82 with SMTP id p79mr7419534lja.32.1507719911172; Wed, 11 Oct 2017 04:05:11 -0700 (PDT) Received: from tdu.semihalf.local (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id g63sm2403444ljf.89.2017.10.11.04.05.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Oct 2017 04:05:10 -0700 (PDT) From: Tomasz Duszynski To: dev@dpdk.org Cc: Tomasz Duszynski , stable@dpdk.org Date: Wed, 11 Oct 2017 13:05:07 +0200 Message-Id: <1507719907-16418-1-git-send-email-tdu@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1507713940-12268-1-git-send-email-tdu@semihalf.com> References: <1507713940-12268-1-git-send-email-tdu@semihalf.com> Subject: [dpdk-dev] [PATCH v2] crypto: use snprintf return value correctly X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Oct 2017 11:05:12 -0000 snprintf return value is the length of was encoded into destination array excluding '\0'. Thus return value equal to the length of the destination array or more means truncation. This commit fixes improper use of the return value. Fixes: eec136f3c54f ("aesni_gcm: add driver for AES-GCM crypto operations") Fixes: 924e84f87306 ("aesni_mb: add driver for multi buffer based crypto") Fixes: 0f548b50a160 ("crypto/aesni_mb: process crypto op on dequeue") Fixes: 169ca3db550c ("crypto/armv8: add PMD optimized for ARMv8 processors") Fixes: 2773c86d061a ("crypto/kasumi: add driver for KASUMI library") Fixes: 94b0ad8e0aa5 ("null_crypto: add driver for null crypto operations") Fixes: d61f70b4c918 ("crypto/libcrypto: add driver for OpenSSL library") Fixes: 3aafc423cf4d ("snow3g: add driver for SNOW 3G library") Fixes: cf7685d68f00 ("crypto/zuc: add driver for ZUC library") Cc: stable@dpdk.org Signed-off-by: Tomasz Duszynski Acked-by: Bruce Richardson --- drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c | 2 +- drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c | 4 ++-- drivers/crypto/armv8/rte_armv8_pmd_ops.c | 2 +- drivers/crypto/kasumi/rte_kasumi_pmd_ops.c | 2 +- drivers/crypto/null/null_crypto_pmd_ops.c | 2 +- drivers/crypto/openssl/rte_openssl_pmd_ops.c | 2 +- drivers/crypto/snow3g/rte_snow3g_pmd_ops.c | 2 +- drivers/crypto/zuc/rte_zuc_pmd_ops.c | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c b/drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c index 48400ac..0f315f0 100644 --- a/drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c +++ b/drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c @@ -195,7 +195,7 @@ aesni_gcm_pmd_qp_set_unique_name(struct rte_cryptodev *dev, "aesni_gcm_pmd_%u_qp_%u", dev->data->dev_id, qp->id); - if (n > sizeof(qp->name)) + if (n >= sizeof(qp->name)) return -1; return 0; diff --git a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c index 2e52ac2..3b3ef0c 100644 --- a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c +++ b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c @@ -397,7 +397,7 @@ aesni_mb_pmd_qp_set_unique_name(struct rte_cryptodev *dev, "aesni_mb_pmd_%u_qp_%u", dev->data->dev_id, qp->id); - if (n > sizeof(qp->name)) + if (n >= sizeof(qp->name)) return -1; return 0; @@ -415,7 +415,7 @@ aesni_mb_pmd_qp_create_processed_ops_ring(struct aesni_mb_qp *qp, "%s_%s", qp->name, str); - if (n > sizeof(ring_name)) + if (n >= sizeof(ring_name)) return NULL; r = rte_ring_lookup(ring_name); diff --git a/drivers/crypto/armv8/rte_armv8_pmd_ops.c b/drivers/crypto/armv8/rte_armv8_pmd_ops.c index 00297be..63776b2 100644 --- a/drivers/crypto/armv8/rte_armv8_pmd_ops.c +++ b/drivers/crypto/armv8/rte_armv8_pmd_ops.c @@ -209,7 +209,7 @@ armv8_crypto_pmd_qp_set_unique_name(struct rte_cryptodev *dev, n = snprintf(qp->name, sizeof(qp->name), "armv8_crypto_pmd_%u_qp_%u", dev->data->dev_id, qp->id); - if (n > sizeof(qp->name)) + if (n >= sizeof(qp->name)) return -1; return 0; diff --git a/drivers/crypto/kasumi/rte_kasumi_pmd_ops.c b/drivers/crypto/kasumi/rte_kasumi_pmd_ops.c index 8033114..4da12f3 100644 --- a/drivers/crypto/kasumi/rte_kasumi_pmd_ops.c +++ b/drivers/crypto/kasumi/rte_kasumi_pmd_ops.c @@ -183,7 +183,7 @@ kasumi_pmd_qp_set_unique_name(struct rte_cryptodev *dev, "kasumi_pmd_%u_qp_%u", dev->data->dev_id, qp->id); - if (n > sizeof(qp->name)) + if (n >= sizeof(qp->name)) return -1; return 0; diff --git a/drivers/crypto/null/null_crypto_pmd_ops.c b/drivers/crypto/null/null_crypto_pmd_ops.c index 7615320..c427050 100644 --- a/drivers/crypto/null/null_crypto_pmd_ops.c +++ b/drivers/crypto/null/null_crypto_pmd_ops.c @@ -175,7 +175,7 @@ null_crypto_pmd_qp_set_unique_name(struct rte_cryptodev *dev, "null_crypto_pmd_%u_qp_%u", dev->data->dev_id, qp->id); - if (n > sizeof(qp->name)) + if (n >= sizeof(qp->name)) return -1; return 0; diff --git a/drivers/crypto/openssl/rte_openssl_pmd_ops.c b/drivers/crypto/openssl/rte_openssl_pmd_ops.c index e1c225d..c572239 100644 --- a/drivers/crypto/openssl/rte_openssl_pmd_ops.c +++ b/drivers/crypto/openssl/rte_openssl_pmd_ops.c @@ -599,7 +599,7 @@ openssl_pmd_qp_set_unique_name(struct rte_cryptodev *dev, "openssl_pmd_%u_qp_%u", dev->data->dev_id, qp->id); - if (n > sizeof(qp->name)) + if (n >= sizeof(qp->name)) return -1; return 0; diff --git a/drivers/crypto/snow3g/rte_snow3g_pmd_ops.c b/drivers/crypto/snow3g/rte_snow3g_pmd_ops.c index ae9569c..157a2de 100644 --- a/drivers/crypto/snow3g/rte_snow3g_pmd_ops.c +++ b/drivers/crypto/snow3g/rte_snow3g_pmd_ops.c @@ -184,7 +184,7 @@ snow3g_pmd_qp_set_unique_name(struct rte_cryptodev *dev, "snow3g_pmd_%u_qp_%u", dev->data->dev_id, qp->id); - if (n > sizeof(qp->name)) + if (n >= sizeof(qp->name)) return -1; return 0; diff --git a/drivers/crypto/zuc/rte_zuc_pmd_ops.c b/drivers/crypto/zuc/rte_zuc_pmd_ops.c index 52c6aed..243c099 100644 --- a/drivers/crypto/zuc/rte_zuc_pmd_ops.c +++ b/drivers/crypto/zuc/rte_zuc_pmd_ops.c @@ -184,7 +184,7 @@ zuc_pmd_qp_set_unique_name(struct rte_cryptodev *dev, "zuc_pmd_%u_qp_%u", dev->data->dev_id, qp->id); - if (n > sizeof(qp->name)) + if (n >= sizeof(qp->name)) return -1; return 0; -- 2.7.4