[New-bugs-announce] [issue36496] Local variables can be used uninitialized in _PyPreConfig_Read()
Brad Larsen
report at bugs.python.org
Sun Mar 31 12:46:03 EDT 2019
New submission from Brad Larsen <brad at bradfordlarsen.com>:
In bpo-36301, in commit f72346c47537657a287a862305f65eb5d7594fbf, a couple possible uses of uninitialized variables were introduced into Python/preconfig.c.
In particular, in _PyPreConfig_Read(), along an error-handling path, the `init_utf8_mode` and `init_legacy_encoding` variables will be read uninitialized.
_PyInitError
_PyPreConfig_Read(_PyPreConfig *config, const _PyArgv *args)
{
/* ... */
if (args) {
err = _PyPreCmdline_SetArgv(&cmdline, args);
if (_Py_INIT_FAILED(err)) {
goto done; /* ERROR HANDLING DONE HERE */
}
}
int init_utf8_mode = Py_UTF8Mode; /* VARIABLE INITIZLIED HERE */
#ifdef MS_WINDOWS
int init_legacy_encoding = Py_LegacyWindowsFSEncodingFlag; /* VARIABLE INITIZLIED HERE */
#endif
/* ... */
done:
if (init_ctype_locale != NULL) {
setlocale(LC_CTYPE, init_ctype_locale);
PyMem_RawFree(init_ctype_locale);
}
_PyPreConfig_Clear(&save_config);
Py_UTF8Mode = init_utf8_mode ; /* UNINITIALIZED READ HERE */
#ifdef MS_WINDOWS
Py_LegacyWindowsFSEncodingFlag = init_legacy_encoding; /* UNINITIALIZED READ HERE */
#endif
_PyPreCmdline_Clear(&cmdline);
return err;
}
----------
components: Interpreter Core
messages: 339268
nosy: blarsen
priority: normal
severity: normal
status: open
title: Local variables can be used uninitialized in _PyPreConfig_Read()
versions: Python 3.8
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36496>
_______________________________________
More information about the New-bugs-announce
mailing list