Skip to content

Commit

Permalink
[3.12] gh-114492: Initialize struct termios before calling tcgetattr() (
Browse files Browse the repository at this point in the history
GH-114495) (GH-114502)

On Alpine Linux it could leave some field non-initialized.
(cherry picked from commit d22c066)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
  • Loading branch information
miss-islington and serhiy-storchaka committed Jan 23, 2024
1 parent f63dec9 commit 386c72d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
@@ -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.
2 changes: 2 additions & 0 deletions Modules/termios.c
Expand Up @@ -84,6 +84,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
Expand Down

0 comments on commit 386c72d

Please sign in to comment.