Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YFyBd-0001d7-Ea for pgsql-bugs@arkaria.postgresql.org; Tue, 27 Jan 2015 04:55:37 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YFyBc-0000Ai-AN for pgsql-bugs@arkaria.postgresql.org; Tue, 27 Jan 2015 04:55:36 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YFUAB-0008FE-DO for pgsql-bugs@postgresql.org; Sun, 25 Jan 2015 20:52:07 +0000 Received: from wrigleys.postgresql.org ([204.145.124.246]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YFUA7-0007fy-0Y for pgsql-bugs@postgresql.org; Sun, 25 Jan 2015 20:52:05 +0000 MIME-Version: 1.0 Subject: BUG #12664: numeric_recv does not accept large values To: pgsql-bugs@postgresql.org From: emil.lenngren@gmail.com Date: Sun, 25 Jan 2015 20:51:46 +0000 Message-ID: <20150125205146.6452.25810@wrigleys.postgresql.org> X-Pg-Spam-Score: -0.3 (/) Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org The following bug has been logged on the website: Bug reference: 12664 Logged by: Emil Lenngren Email address: emil.lenngren@gmail.com PostgreSQL version: 9.4.0 Operating system: N/A Description: According to the documentation for data type "numeric" at http://www.postgresql.org/docs/9.4/static/datatype-numeric.html: "up to 131072 digits before the decimal point; up to 16383 digits after the decimal point" "Note: The maximum allowed precision when explicitly specified in the type declaration is 1000; NUMERIC without a specified precision is subject to the limits described in Table 8-2." In the binary representation, digits are grouped into groups of 4. The number of such groups is checked in numeric_recv: len = (uint16) pq_getmsgint(buf, sizeof(uint16)); if (len < 0 || len > NUMERIC_MAX_PRECISION + NUMERIC_MAX_RESULT_SCALE) ereport(ERROR, (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION), errmsg("invalid length in external \"numeric\" value"))); but NUMERIC_MAX_PRECISION + NUMERIC_MAX_RESULT_SCALE is 3000 which means a limit of only 12000 digits. numeric_in has no such limit. The guard should check something like (len > ceil((131072+16383)/4)) instead, or not at all, since the function make_result also checks the length. Checking for len < 0 also seems a bit needless since len already contains an unsigned 16-bit value. -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs