Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/pr/192'
Browse files Browse the repository at this point in the history
* origin/pr/192:
  Fix checking for memory allocation errors
  • Loading branch information
marmarek committed Feb 26, 2025
2 parents ac49115 + b90eb2c commit c4ecaad
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions agent/qrexec-agent.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,23 +196,31 @@ _Noreturn void do_exec(const char *prog, const char *cmd, const char *user)
*/
pw_copy = *pw;
pw = &pw_copy;
pw->pw_name = strdup(pw->pw_name);
pw->pw_passwd = strdup(pw->pw_passwd);
pw->pw_dir = strdup(pw->pw_dir);
pw->pw_shell = strdup(pw->pw_shell);
if (!((pw->pw_name = strdup(pw->pw_name)) &&
(pw->pw_passwd = strdup(pw->pw_passwd)) &&
(pw->pw_dir = strdup(pw->pw_dir)) &&
(pw->pw_shell = strdup(pw->pw_shell)))) {
PERROR("strdup");
exit(QREXEC_EXIT_PROBLEM);
}
endpwent();

shell_basename = basename (pw->pw_shell);
/* this process is going to die shortly, so don't care about freeing */
arg0 = malloc (strlen (shell_basename) + 2);
if (!arg0)
goto error;
if (!arg0) {
PERROR("malloc");
exit(QREXEC_EXIT_PROBLEM);
}
arg0[0] = '-';
strcpy (arg0 + 1, shell_basename);

retval = pam_start("qrexec", user, &conv, &pamh);
if (retval != PAM_SUCCESS)
if (retval != PAM_SUCCESS) {
LOG(ERROR, "PAM handle could not be acquired");
pamh = NULL;
goto error;
}

retval = pam_authenticate(pamh, 0);
if (retval != PAM_SUCCESS)
Expand Down

0 comments on commit c4ecaad

Please sign in to comment.