]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
Treat out of memory as error
authorTobias Stoeckmann <tobias@stoeckmann.org>
Mon, 12 Aug 2024 15:37:03 +0000 (17:37 +0200)
committerTobias Stoeckmann <tobias@stoeckmann.org>
Mon, 12 Aug 2024 15:37:03 +0000 (17:37 +0200)
Otherwise it might happen that a configured file location is not taken
into account. A NULL value would lead to default file location.

pam_lastlog2/src/pam_lastlog2.c

index e800700bf5879595c41b7691318409cd13d85422..c3ca989c1cb9381cb06fe27c8d04cadc068b205f 100644 (file)
@@ -189,6 +189,8 @@ write_login_data (pam_handle_t *pamh, int ctrl, const char *user)
                return PAM_SYSTEM_ERR;
 
        struct ll2_context *context = ll2_new_context(lastlog2_path);
+       if (context == NULL)
+               return PAM_SYSTEM_ERR;
        if (ll2_write_entry (context, user, ll_time, tty, rhost,
                             pam_service, &error) != 0) {
                if (error) {
@@ -220,6 +222,8 @@ show_lastlogin (pam_handle_t *pamh, int ctrl, const char *user)
                return retval;
 
        struct ll2_context *context = ll2_new_context(lastlog2_path);
+       if (context == NULL)
+               return PAM_SYSTEM_ERR;
        if (ll2_read_entry (context, user, &ll_time, &tty, &rhost,
                            &service, &error) != 0) {
                if (errno == ENOENT)