gh-114492: Initialize struct termios before calling tcgetattr() (GH-114495)

On Alpine Linux it could leave some field non-initialized.
This commit is contained in:
Serhiy Storchaka 2024-01-23 23:27:04 +02:00 committed by GitHub
parent ce01ab536f
commit d22c066b80
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 0 deletions

View File

@ -0,0 +1,2 @@
Make the result of :func:`termios.tcgetattr` reproducible on Alpine Linux.
Previously it could leave a random garbage in some fields.

View File

@ -98,6 +98,8 @@ termios_tcgetattr_impl(PyObject *module, int fd)
struct termios mode;
int r;
/* Alpine Linux can leave some fields uninitialized. */
memset(&mode, 0, sizeof(mode));
Py_BEGIN_ALLOW_THREADS
r = tcgetattr(fd, &mode);
Py_END_ALLOW_THREADS