Fix ASAN failure after flex errors in GUC file parsing As detected by ASAN, the scanner value used when parsing GUC files can be indeterminate when the flex error handler sigjumps to the old cleanup path, before yylex_init() is called.
The flex scanner state is now made volatile in ParseConfigFp(), since its value is assigned after sigsetjmp() and cna be accessed after siglongjmp(). yylex_init() cannot use a volatile pointer; a temporary variable is used before assigning the result of yylex_init() to it. While on it, yy_create_buffer() is changed to detect the case where it returns a NULL value. Based on my read of the flex code, this cannot be reached currently. Future upstream changes or changes in the error logic of the GUC file parsing could make that reachable, and it is four extra lines of code. Oversight in d663f150b5ed. Reported-by: Ilia Kashintsev <[email protected]> Reviewed-by: Tom Lane <[email protected]> Reviewed-by: Andrey Rachitskiy <[email protected]> Discussion: https://postgr.es/m/[email protected] Backpatch-through: 18 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/803583ce74d37c27167bd4d1c9e9dd2421735943 Modified Files -------------- src/backend/utils/misc/guc-file.l | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-)
