summaryrefslogtreecommitdiff
path: root/src/man/begin.l
diff options
context:
space:
mode:
authorMichael Paquier2025-07-22 23:18:36 +0000
committerMichael Paquier2025-07-22 23:18:36 +0000
commita6eabec6808cb1b8f20974ad57275b14fc079e3b (patch)
treedd618fe3405f4a3075d79eecceeae074dbce33de /src/man/begin.l
parenta7ca73af662bc95e14058ac3f8fcf5d257f8bf79 (diff)
ecpg: Improve error detection around ecpg_strdup()
Various code paths of the ECPG code did not check for memory allocation failures, including the specific case where ecpg_strdup() considers a NULL value given in input as a valid behavior. strdup() returning itself NULL on failure, there was no way to make the difference between what could be valid and what should fail. With the different cases in mind, ecpg_strdup() is redesigned and gains a new optional argument, giving its callers the possibility to differentiate allocation failures and valid cases where the caller is giving a NULL value in input. Most of the ECPG code does not expect a NULL value, at the exception of ECPGget_desc() (setlocale) and ECPGconnect(), like dbname being unspecified, with repeated strdup calls. The code is adapted to work with this new routine. Note the case of ecpg_auto_prepare(), where the code order is switched so as we handle failures with ecpg_strdup() before manipulating any cached data, avoiding inconsistencies. This class of failure is unlikely a problem in practice, so no backpatch is done. Random OOM failures in ECPGconnect() could cause the driver to connect to a different server than the one wanted by the caller, because it could fallback to default values instead of the parameters defined depending on the combinations of allocation failures and successes. Author: Evgeniy Gorbanev <gorbanyoves@basealt.ru> Co-authored-by: Aleksander Alekseev <aleksander@tigerdata.com> Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de> Reviewed-by: Michael Paquier <michael@paquier.xyz> Discussion: https://postgr.es/m/a6b193c1-6994-4d9c-9059-aca4aaf41ddd@basealt.ru
Diffstat (limited to 'src/man/begin.l')
0 files changed, 0 insertions, 0 deletions