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 6F44A200CE0 for ; Fri, 11 Aug 2017 05:29:26 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 6DC5216CC09; Fri, 11 Aug 2017 03:29:26 +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 DA72716CC08 for ; Fri, 11 Aug 2017 05:29:25 +0200 (CEST) Received: (qmail 75620 invoked by uid 500); 11 Aug 2017 03:29:25 -0000 Mailing-List: contact dev-help@thrift.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@thrift.apache.org Delivered-To: mailing list dev@thrift.apache.org Received: (qmail 75609 invoked by uid 99); 11 Aug 2017 03:29:24 -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; Fri, 11 Aug 2017 03:29:24 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 9265CF17F6; Fri, 11 Aug 2017 03:29:24 +0000 (UTC) From: asuhan To: dev@thrift.apache.org Reply-To: dev@thrift.apache.org References: In-Reply-To: Subject: [GitHub] thrift pull request #1326: THRIFT-3821 Content-Type: text/plain Message-Id: <20170811032924.9265CF17F6@git1-us-west.apache.org> Date: Fri, 11 Aug 2017 03:29:24 +0000 (UTC) archived-at: Fri, 11 Aug 2017 03:29:26 -0000 Github user asuhan commented on a diff in the pull request: https://github.com/apache/thrift/pull/1326#discussion_r132612265 --- Diff: lib/cpp/src/thrift/transport/TBufferTransports.cpp --- @@ -361,9 +361,13 @@ void TMemoryBuffer::ensureCanWrite(uint32_t len) { } // Grow the buffer as necessary. - uint32_t new_size = bufferSize_; + uint64_t new_size = bufferSize_; while (len > avail) { new_size = new_size > 0 ? new_size * 2 : 1; + if (new_size > std::numeric_limits::max()) { --- End diff -- We check it post-resize and it fails if we go past 4 GB, therefore pre-resize it must be at most 2GB. Checking against `int32_t` would be overly conservative; we mainly care about avoiding the arithmetic overflow. Maybe the error message could be improved? `"Internal buffer size was already past 2GB when we attempted to resize"` would be a more precise description, but I didn't want to make it overly verbose / obscure. --- 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. ---