[PATCH] libpwdgrp: fix relying on unknown errno state
Adam Goldman
adamg at pobox.com
Wed Mar 5 09:29:26 UTC 2025
On Tue, Feb 25, 2025 at 03:35:47PM +0200, Baruch Burstein wrote:
> To give some context:
> At loginutils/login.c:502 `is_tty_secure()` is called. This function
> (at libbb/securetty.c:10) attempts to open "/etc/securetty". If the file is
> not found this is not an error (see comment there), but it does set errno.
> A few lines later, login.c calls `ask_and_check_password()`, which
> eventually reaches `massage_data_for_r_func()`, which returns a failure if
> errno is set at the end of the function.
So the problem (which your patch fixes) is that if errno is nonzero at
entry to massage_data_for_r_func, the RETURN VALUE of
massage_data_for_r_func is wrong, because massage_data_for_r_func ends
in "return errno;". But a library function should avoid clearing errno.
It might be better to have it return 0 and leave errno alone.
-- Adam
More information about the busybox
mailing list