Skip to content

Commit

Permalink
Merge pull request #285 from ubuntu/pam_fixes
Browse files Browse the repository at this point in the history
pam_adsys: Fix memory leak and identation
  • Loading branch information
jibel committed Feb 21, 2022
2 parents 9f48a23 + 1c7dc55 commit 20e6f96
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pam/pam_adsys.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ static int update_policy(pam_handle_t * pamh, const char *username, const char *
execv(arggv[0], arggv);
int i = errno;
pam_syslog(pamh, LOG_ERR, "execv(%s,...) failed: %m", arggv[0]);
free(arggv);
_exit(i);
}

Expand Down Expand Up @@ -207,6 +208,7 @@ static int update_machine_policy(pam_handle_t * pamh, int debug)
execv(arggv[0], arggv);
int i = errno;
pam_syslog(pamh, LOG_ERR, "execv(%s,...) failed: %m", arggv[0]);
free(arggv);
_exit(i);
}

Expand Down Expand Up @@ -294,10 +296,10 @@ pam_sm_open_session(pam_handle_t * pamh, int flags, int argc, const char **argv)
*/
char hostname[HOST_NAME_MAX + 1];
char cache_path[HOST_NAME_MAX + 1 + strlen(ADSYS_POLICIES_DIR) - 2];
if (gethostname(hostname, HOST_NAME_MAX + 1) < 0) {
if (gethostname(hostname, HOST_NAME_MAX + 1) < 0) {
pam_syslog(pamh, LOG_ERR, "Failed to get hostname");
return PAM_SYSTEM_ERR;
}
}
if (sprintf(cache_path, ADSYS_POLICIES_DIR, hostname) < 0) {
pam_syslog(pamh, LOG_ERR, "Failed to allocate cache_path");
return PAM_BUF_ERR;
Expand Down

0 comments on commit 20e6f96

Please sign in to comment.