Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1npPEN-0007Jn-Mq for pgsql-bugs@arkaria.postgresql.org; Fri, 13 May 2022 06:56:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1npPEM-0008OC-Ay for pgsql-bugs@arkaria.postgresql.org; Fri, 13 May 2022 06:56:54 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1npPEL-0008Lh-Rl for pgsql-bugs@lists.postgresql.org; Fri, 13 May 2022 06:56:54 +0000 Received: from mail.postgrespro.ru ([93.174.131.139]) by makus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1npPEE-00057y-Ek for pgsql-bugs@lists.postgresql.org; Fri, 13 May 2022 06:56:52 +0000 Received: from [192.168.28.53] (cyclops.postgrespro.ru [93.174.131.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id E309621C7DC2 for ; Fri, 13 May 2022 09:56:43 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1652425004; bh=xiJzbnrO1gELKIgyWxkJOMmdJRPAY+LFJoEtLoGISmk=; h=Date:To:From:Subject; b=mR8gE7g+SMVSwSNdetr2/5P+kgvncvAW7HBWl91SngM1TLKFtdX8hOkwrq4Q+Ais8 LblqvZB7J/P8ASmbp9CeoElAZe6ituclwTNfbb9RZfA+EmFLtUwWnl/AGVGMXqOdgO /DD1MIXPLuhGgsgODTidLljWO7I4MQLem9pNb6gE= Message-ID: Date: Fri, 13 May 2022 11:56:43 +0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Content-Language: en-US To: pgsql-bugs@lists.postgresql.org From: Andrey Lepikhov Subject: Negative value of numGroups Organization: Postgres Professional Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, Using sqlancer I've found curious vulnerability. In some places of the code we convert LONG_MAX to double. After value of 2^53 double doesn't correspond to a long value precisely. So, LONG_MAX can be converted into 'LONG_MAX + 1' double value. And string: (long) Min(numGroups, (double) LONG_MAX); can return negative value, if numGroups > LONG_MAX. Maybe it isn't practical issue right now, but this annoying thing doesn't allow to pass sqlancer tests sometimes, for example, with options: --extensions='pg_stat_statements' --oracle HAVING It is not difficult to fix the problem in-place, of course. But maybe do better: change the type of numGroups field in any Plan nodes to double and convert it into specific type right before usage? -- Regards Andrey Lepikhov Postgres Professional