]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
pam_exec: fix segfault when authtok is null
authorYan Ka Chiu <nyan@myuji.xyz>
Sun, 22 May 2022 16:33:02 +0000 (12:33 -0400)
committerMark Johnston <markj@FreeBSD.org>
Mon, 25 Jul 2022 21:01:46 +0000 (17:01 -0400)
commit26db194f3db1238b9339bde23a82def8cfee10b1
treec15e9da288d229887a9e7a18b08131c0e5ca5b77
parentc48048ebdbed0901dacf1632af3b3db600533e64
pam_exec: fix segfault when authtok is null

According to pam_exec(8), the `expose_authtok` option should be ignored
when the service function is `pam_sm_setcred`. Currently `pam_exec` only
prevent prompt for anth token when `expose_authtok` is set on
`pam_sm_setcred`. This subsequently led to segfault when there isn't an
existing auth token available.

Bug reported on this: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=263893

After reading https://reviews.freebsd.org/rS349556 I am not sure if the
default behaviour supposed to be simply not prompt for authentication
token, or is it to ignore the option entirely as stated in the man page.

This patch is therefore only adding an additional NULL check on the item
`pam_get_item` provide, and exit with `PAM_SYSTEM_ERR` when such item is
NULL.

Approved by: so
Security: FreeBSD-EN-22:19.pam_exec
MFC after: 1 week
Reviewed by: des, khng
Differential Revision: https://reviews.freebsd.org/D35169

(cherry picked from commit b75e0eed345d2ab047a6b1b00a9a7c3bf92e992c)
(cherry picked from commit ea80848e1c0639e2ac8d3f974ddb9c6233491eb3)
lib/libpam/modules/pam_exec/pam_exec.c