Potential issue in ecpg-informix decimal converting functions
Aidar Imamov <a.imamov@postgrespro.ru>
From: a.imamov@postgrespro.ru
To: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2024-02-22T16:54:37Z
Lists: pgsql-hackers
Attachments
- informix_convert_from_decimal.patch (text/x-diff) patch
Hi, everyone! I found a potential bug in dectoint() and dectolong() functions from informix.c. "Informix Compatibility Mode" doc chapter says that ECPG_INFORMIX_NUM_OVERFLOW is returned if an overflow occurred. But check this line in dectoint() or dectolong() (it is present in both): if (ret == PGTYPES_NUM_OVERFLOW) - condition is always false because PGTYPESnumeric_to_int() and PGTYPESnumeric_to_long() functions return only 0 or -1. So ECPG_INFORMIX_NUM_OVERFLOW can never be returned. I think dectoint(), dectolong() and PGTYPESnumeric_to_int() functions should be a little bit different like in proposing patch. What do you think? The flaw was catched with the help of Svace static analyzer. https://svace.pages.ispras.ru/svace-website/en/ Thank you!
Commits
-
doc: Document error handling in PGTYPESnumeric_to_long
- 68174679fea2 17.0 landed
-
ecpg: Fix return code for overflow in numeric conversion
- b2d6b4c728a2 17.0 landed