-
Notifications
You must be signed in to change notification settings - Fork 254
lib/utmp.c: Fix use of last utmp entry instead of patrial-match entry #1326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lib/utmp.c: Fix use of last utmp entry instead of patrial-match entry #1326
Conversation
|
@ikerexxe Please, take a look on it. |
3e684ab to
fa3c354
Compare
|
Updated with separated fix and refactors. The fix is really simple. Can be used alone, without refactors. |
fa3c354 to
b8a06bc
Compare
|
Added an alternative version #1327 with full revert as the first commit. |
b8a06bc to
be066b9
Compare
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>
be066b9 to
92fd0eb
Compare
alejandro-colomar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! LGTM.
|
Thank you! |
No problem! Mistakes happen to everyone. :) |
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).