From 4780cd1a790286213dda646f782fa7128fb092a9 Mon Sep 17 00:00:00 2001 From: Yugend <77495782+Yugend@users.noreply.github.com> Date: Sat, 4 May 2024 00:39:36 +0300 Subject: [PATCH] avoiding of NULL pointers dereference (#366) --- src/ausearch-parse.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/ausearch-parse.c b/src/ausearch-parse.c index 1a5b047f3..be57606bd 100644 --- a/src/ausearch-parse.c +++ b/src/ausearch-parse.c @@ -719,6 +719,10 @@ static int common_path_parser(search_items *s, char *path) // append snode sn; sn.str = strdup(path); + if (sn.str == NULL) { + fprintf(stderr, "Out of memory. Check %s file, %d line\n", __FILE__, __LINE__); + return 8; + } sn.key = NULL; sn.hits = 1; // Attempt to rebuild path if relative @@ -1217,6 +1221,10 @@ static int parse_user(const lnode *n, search_items *s, anode *avc) saved = *term; *term = 0; s->hostname = strdup(str); + if (s->hostname == NULL) { + fprintf(stderr, "Out of memory. Check %s file, %d line\n", __FILE__, __LINE__); + return 33; + } *term = saved; // Lets see if there is something more