From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf0-f51.google.com (mail-lf0-f51.google.com [209.85.215.51]) by dpdk.org (Postfix) with ESMTP id 6DABD1B18C for ; Wed, 11 Oct 2017 11:25:56 +0200 (CEST) Received: by mail-lf0-f51.google.com with SMTP id l23so1330593lfk.10 for ; Wed, 11 Oct 2017 02:25:56 -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; bh=uea/Gb0/kE5FcQqo/IanvUIsX6injLgOps/YSaDbWeA=; b=jd/HkrPLC3OaY4gTSX01UWX74NahrlgZWKzVMLYHz6MPIXhda6pbnZwZW/inncZ8cC iq3OlQLA+xGcfPOedITaO//4O9uvVxrpUxsZVP02cfV4Mv43LWBeugQOE1TLSbCoCY6l HtjgxzrtDcp5BBpLUWXGkF3zjh5i1TwgCrxN+OFtOyBIIG/3zgeydtpvXHZXOgQXumhE lN20TTI6df+iIw0AvMo8Wn+Kdo3uZ/j7BVkaVlM9TiWIqyCL9lFEBOfFeqR4gJg34et2 nTuxhKRGL9NAiOOQN8PtMpd5HI5CgfNnRh7pN/xm/43jrGX9HaO/vcN9PYfim6sYQlZB vmZw== 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; bh=uea/Gb0/kE5FcQqo/IanvUIsX6injLgOps/YSaDbWeA=; b=g8liUnRjFzNdsGYEn73HXbtcIy6kYNR8K0j6YIvHh7tKByPybyLOQ9oNnOys11oAi8 4R4lyPrbOa8tU4S2DAhtDDBVD1f1w26Nw2FZqhdki7wfKuOSLTtsZGCkJi7XFA3H1MJE ErDeUWEdgoy17t5samc9Lf6OKucobdrBTSrlyt+lN8/pQ948jp7c6TQ8I/vYX2z2CHfa e0uOMXFQyXRiXM4/ASnNfILHQ23qWKCGwvllYVMG8Db90gko4gEZdyLmgSWUaxKKnsHE jp06fChX0+MS/suHuvRQkdhZ6L1KeIOzPcphxF8rN//1/O+i9ppJd6tc+WIHvhAgxmRu jGug== X-Gm-Message-State: AMCzsaXnQXdnyAVZbEFDgaMe4IheMKfWma0Sz2BU4Ysqtn3DmIWQdn0u dWKCuvPiw0S1jdUeZYYOUm75wQN+eMQ= X-Google-Smtp-Source: AOwi7QCKKPDVP00jbz5eT6FHN3Zdo0N5S0GVwINyfSpOxkeianaT36DnWkHy45ELI+niaVDlasOQqA== X-Received: by 10.25.20.29 with SMTP id k29mr6146331lfi.111.1507713955487; Wed, 11 Oct 2017 02:25:55 -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 2sm613548lju.45.2017.10.11.02.25.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Oct 2017 02:25:54 -0700 (PDT) From: Tomasz Duszynski To: dev@dpdk.org Cc: Tomasz Duszynski Date: Wed, 11 Oct 2017 11:25:40 +0200 Message-Id: <1507713940-12268-1-git-send-email-tdu@semihalf.com> X-Mailer: git-send-email 2.7.4 Subject: [dpdk-dev] [PATCH] 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 09:25:56 -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. Signed-off-by: Tomasz Duszynski --- 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