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
1 changed files with 5 additions and 4 deletions

View File

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