From 654b85488b128aab5baf8feee71f38b763425d56 Mon Sep 17 00:00:00 2001 From: Tomas Mraz Date: Tue, 21 Apr 2020 09:30:03 +0200 Subject: [PATCH] Handle out-of-memory condition from mkprints() call --- src/do_command.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/do_command.c b/src/do_command.c index d1594c6..b4f1d18 100644 --- a/src/do_command.c +++ b/src/do_command.c @@ -194,6 +194,9 @@ static int child_process(entry * e, char **jobenv) { if ((e->flags & DONT_LOG) == 0) { char *x = mkprints((u_char *) e->cmd, strlen(e->cmd)); + if (x == NULL) /* out of memory, better exit */ + _exit(ERROR_EXIT); + log_it(usernm, getpid(), "CMD", x, 0); free(x); } @@ -592,7 +595,7 @@ static int child_process(entry * e, char **jobenv) { if ((e->flags & DONT_LOG) == 0) { char *x = mkprints((u_char *) e->cmd, strlen(e->cmd)); - log_it(usernm, getpid(), "CMDEND", x ? x : "Unknown command" , 0); + log_it(usernm, getpid(), "CMDEND", x ? x : "**Unknown command**" , 0); free(x); } return OK_EXIT; -- 1.8.3.1