Skip to content

Conversation

@Karlson2k
Copy link
Contributor

When no "ut_id" is provided by previous utmp file entry, "login" must generate its own "ut_id". Historically tty number was used for it. However, if current device name is three characters or shorter, then empty "ut_id" is produced or even garbage is copied from uninitialised part of the "line".
This commit fixes it.
This patch uses unportable C extension Elvis operator as it is already used everywhere in the code.

Extracted from #1293

When no "ut_id" is provided by previous utmp file entry, "login" must
generate its own "ut_id". Historically tty number  was used for it.
However, if current device name is three characters or shorter, then
empty "ut_id" is produced or even garbage is copied from uninitialised
part of the "line".
This commit fixes it.
This patch uses unportable C extension Elvis operator as it is already
used everywhere in the code.

Signed-off-by: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
Copy link
Collaborator

@alejandro-colomar alejandro-colomar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Reviewed-by: Alejandro Colomar <alx@kernel.org>

@alejandro-colomar alejandro-colomar merged commit f86d60f into shadow-maint:master Jul 17, 2025
10 checks passed
@Karlson2k Karlson2k deleted the fix-ut_id branch July 17, 2025 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants