Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 6837B200B9B for ; Wed, 12 Oct 2016 23:29:09 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 669C6160AD4; Wed, 12 Oct 2016 21:29:09 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id D43F7160ACA for ; Wed, 12 Oct 2016 23:29:08 +0200 (CEST) Received: (qmail 13982 invoked by uid 500); 12 Oct 2016 21:29:07 -0000 Mailing-List: contact dev-help@accumulo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@accumulo.apache.org Delivered-To: mailing list dev@accumulo.apache.org Received: (qmail 13963 invoked by uid 99); 12 Oct 2016 21:29:07 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Oct 2016 21:29:07 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 0FA8DDFB78; Wed, 12 Oct 2016 21:29:07 +0000 (UTC) From: ctubbsii To: dev@accumulo.apache.org Reply-To: dev@accumulo.apache.org References: In-Reply-To: Subject: [GitHub] accumulo pull request #163: ACCUMULO-2278 Return value from in.read() should... Content-Type: text/plain Message-Id: <20161012212907.0FA8DDFB78@git1-us-west.apache.org> Date: Wed, 12 Oct 2016 21:29:07 +0000 (UTC) archived-at: Wed, 12 Oct 2016 21:29:09 -0000 Github user ctubbsii commented on a diff in the pull request: https://github.com/apache/accumulo/pull/163#discussion_r83102811 --- Diff: core/src/main/java/org/apache/accumulo/core/security/crypto/NonCachingSecretKeyEncryptionStrategy.java --- @@ -81,7 +81,10 @@ private void doKeyEncryptionOperation(int encryptionMode, CryptoModuleParameters Cipher cipher = DefaultCryptoModuleUtils.getCipher(params.getAllOptions().get(Property.CRYPTO_DEFAULT_KEY_STRATEGY_CIPHER_SUITE.getKey())); try { - cipher.init(encryptionMode, new SecretKeySpec(keyEncryptionKey, params.getAlgorithmName())); + if (keyEncryptionKey.length > 0) --- End diff -- The original reported issue is that the return value of the read is not captured or checked. The conditional being checked here only verifies that the allocated array was larger than an empty array. What it actually needs to check is that the number of bytes read into the array is the same as the value of the length field, regardless of what else we want to check. The conditional in this patch is sufficient only if we switch to using `readFully` instead of `read`, which throws an EOFException if the number of bytes read from the input stream isn't enough to fill the buffer (e.g. doesn't match the expected keyEncryptionKeyLength). --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastructure@apache.org or file a JIRA ticket with INFRA. ---