Skip to content

Conversation

@Karlson2k
Copy link
Contributor

@Karlson2k Karlson2k commented Aug 10, 2025

This is a correction for PR #1292.

After additional code and documentation analysis I found out that copy of the pointer is not enough, a deep copy must be used instead.
I also checked glibc sources to be absolutely sure.

I think this kind of code could be improved with additional comments, as currently it is not fully clear that match by PID has priority over match by line (tty).

@Karlson2k
Copy link
Contributor Author

@ikerexxe Please, take a look on it.

@Karlson2k Karlson2k force-pushed the utmp_entry_correction branch 2 times, most recently from 3e684ab to fa3c354 Compare August 10, 2025 12:15
@Karlson2k
Copy link
Contributor Author

Updated with separated fix and refactors.

The fix is really simple. Can be used alone, without refactors.

@Karlson2k
Copy link
Contributor Author

Added an alternative version #1327 with full revert as the first commit.

The pointer returned by getutxent() function may always point to
the same shared and reused buffer.

Instead of copying the utmp entry pointer value the content of utmp
entry must be copied otherwise the next call of getutxent() will
overwrite previously found entry.

This commit has no optimisations to highlight what is really fixed.

Fixes: 8417765 (09-08-2025; "lib/utmp.c: Fix umtp entry search")
Signed-off-by: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
@Karlson2k Karlson2k force-pushed the utmp_entry_correction branch from be066b9 to 92fd0eb Compare August 10, 2025 13:44
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! LGTM.

@alejandro-colomar alejandro-colomar merged commit 5958f65 into shadow-maint:master Aug 10, 2025
10 checks passed
@Karlson2k
Copy link
Contributor Author

Thank you!
Sorry for missing this in the initial PR.
I'm glad that I spotted it before the next release.

@Karlson2k Karlson2k deleted the utmp_entry_correction branch August 10, 2025 14:11
@alejandro-colomar
Copy link
Collaborator

Thank you! Sorry for missing this in the initial PR. I'm glad that I spotted it before the next release.

No problem! Mistakes happen to everyone. :)

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