busybox: handle crypt() errors in loginutils
authorJo-Philipp Wich <jo@mein.io>
Tue, 22 Jan 2019 11:01:09 +0000 (12:01 +0100)
committerJo-Philipp Wich <jo@mein.io>
Tue, 22 Jan 2019 11:08:00 +0000 (12:08 +0100)
The crypt(3) function is allowed to fail with either EINVAL or ENOSYS when
the given salt is either invalid or when the requested algorithm is not
implemented.

In such a case, libbb's pw_encrypt() function will silently convert the
crypt() NULL return value into an empty string which is then processed
without further errors by utilities such as chpasswd or passwd, causing
them to set an empty password when an unsupported cipher is requested.

Patch the relevant users of pw_encrypt() to abort in case an empty hash
is returned by pw_encrypt() in order to mitigate the problem.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>

No differences found