Resolve segfault with auditing commands (#1203900)

This commit is contained in:
Jakub Jelen 2015-03-20 15:06:06 +01:00
parent 114dfef6d3
commit acf98854ca

View File

@ -1895,7 +1895,7 @@ diff -up openssh-6.8p1/session.c.audit openssh-6.8p1/session.c
- PRIVSEP(audit_run_command(shell));
+ s->command = xstrdup(shell);
}
+ if (s->command != NULL && s->ttyfd == -1)
+ if (s->command != NULL && s->ptyfd == -1)
+ s->command_handle = PRIVSEP(audit_run_command(s->command));
#endif
if (s->ttyfd != -1)
@ -1940,7 +1940,7 @@ diff -up openssh-6.8p1/session.c.audit openssh-6.8p1/session.c
session_by_tty(char *tty)
{
int i;
@@ -2532,6 +2561,30 @@ session_exit_message(Session *s, int sta
@@ -2532,6 +2561,31 @@ session_exit_message(Session *s, int sta
chan_write_failed(c);
}
@ -1948,8 +1948,9 @@ diff -up openssh-6.8p1/session.c.audit openssh-6.8p1/session.c
+void
+session_end_command2(Session *s)
+{
+ if (s->command != NULL && s->ttyfd == -1) {
+ audit_end_command(s->command_handle, s->command);
+ if (s->command != NULL) {
+ if (s->ptyfd == -1)
+ audit_end_command(s->command_handle, s->command);
+ free(s->command);
+ s->command = NULL;
+ s->command_handle = -1;