From patchwork Thu Apr 7 13:07:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Kulasek X-Patchwork-Id: 11971 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 667A52965; Thu, 7 Apr 2016 15:10:29 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id F3A7C28F2 for ; Thu, 7 Apr 2016 15:10:27 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP; 07 Apr 2016 06:07:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,449,1455004800"; d="scan'208";a="950106296" Received: from unknown (HELO Sent) ([10.217.248.18]) by orsmga002.jf.intel.com with SMTP; 07 Apr 2016 06:07:36 -0700 Received: by Sent (sSMTP sendmail emulation); Thu, 07 Apr 2016 15:07:34 +0200 From: Tomasz Kulasek To: dev@dpdk.org Date: Thu, 7 Apr 2016 15:07:30 +0200 Message-Id: <1460034450-9360-1-git-send-email-tomaszx.kulasek@intel.com> X-Mailer: git-send-email 2.1.4 Subject: [dpdk-dev] [PATCH] app/test: fix array subscript is above array bounds for gcc 4.5 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" cc1: warnings being treated as errors DPDK/app/test/test_cryptodev.c: In function 'test_snow3g_encrypted_authenti cation.clone.3': DPDK/x86_64-ivshmem-linuxapp-gcc/include/rte_memcpy.h:796:14: error: array subscript is above array bounds compilation terminated due to -Wfatal-errors. ROOT OF PROBLEM: ---------------- In lines like: rte_memcpy(sym_op->cipher.iv.data, iv, iv_len); when "iv" is 64 bytes long array, and "iv_len" is "unsigned int", compiler tries to evaluate also a code for array size larger than 255 bytes long and reports error "array subscript is above array bounds" in line: rte_memcpy.h:796 rte_mov128((uint8_t *)dst + 128, (const uint8_t *)src + 128); caused by evaluation to: rte_mov128((uint8_t *)sym_op->cipher.iv.data + 128, (const uint8_t *)iv + 128); where "iv" is 64 bytes long buffer and "iv + 128" point out of it, gcc 4.5. SOLUTION: --------- Using uint8_t as a size of copied block prevents to evaluate in rte_memcpy code for size bigger than 255, causing the problem. Signed-off-by: Tomasz Kulasek --- app/test/test_cryptodev.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c index 0c26804..8e8da98 100644 --- a/app/test/test_cryptodev.c +++ b/app/test/test_cryptodev.c @@ -2362,10 +2362,10 @@ create_snow3g_hash_operation(const uint8_t *auth_tag, static int create_snow3g_cipher_hash_operation(const uint8_t *auth_tag, const unsigned auth_tag_len, - const uint8_t *aad, const unsigned aad_len, + const uint8_t *aad, const uint8_t aad_len, unsigned data_pad_len, enum rte_crypto_auth_operation op, - const uint8_t *iv, const unsigned iv_len, + const uint8_t *iv, const uint8_t iv_len, const unsigned cipher_len, const unsigned cipher_offset, const unsigned auth_len, const unsigned auth_offset) { @@ -2460,8 +2460,8 @@ create_snow3g_cipher_hash_operation(const uint8_t *auth_tag, static int create_snow3g_auth_cipher_operation(const unsigned auth_tag_len, - const uint8_t *iv, const unsigned iv_len, - const uint8_t *aad, const unsigned aad_len, + const uint8_t *iv, const uint8_t iv_len, + const uint8_t *aad, const uint8_t aad_len, unsigned data_pad_len, const unsigned cipher_len, const unsigned cipher_offset, const unsigned auth_len, const unsigned auth_offset)