Skip to content

Commit

Permalink
gh-114492: Initialize struct termios before calling tcgetattr() (GH-1…
Browse files Browse the repository at this point in the history
…14495)

On Alpine Linux it could leave some field non-initialized.
  • Loading branch information
serhiy-storchaka committed Jan 23, 2024
1 parent ce01ab5 commit d22c066
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d22c066

Please sign in to comment.