aboutsummaryrefslogtreecommitdiffstats
path: root/main/audit/0003-all-get-rid-of-strndupa.patch
blob: d8317e17fe9ec392e22c32cfd48f592b8324a0da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
From 38d950e468c1e51937530f884b138076e4897da2 Mon Sep 17 00:00:00 2001
From: Tycho Andersen <tycho@docker.com>
Date: Mon, 13 Mar 2017 16:40:08 -0700
Subject: [PATCH 3/4] all: get rid of strndupa

in one case (src/auditd.c) we don't even need to allocate a buffer, in the
other two we do it in two steps to avoid using a non-standard function.

Signed-off-by: Tycho Andersen <tycho@docker.com>
---
 auparse/auparse.c  |  6 ++++--
 src/auditd.c       | 10 +++++-----
 src/ausearch-lol.c |  6 ++++--
 3 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/auparse/auparse.c b/auparse/auparse.c
index 058f544..f61d204 100644
--- a/auparse/auparse.c
+++ b/auparse/auparse.c
@@ -1102,10 +1102,12 @@ static int extract_timestamp(const char *b, au_event_t *e)
 	int rc = 1;
 
         e->host = NULL;
+
+	tmp = alloca(340);
 	if (*b == 'n')
-		tmp = strndupa(b, 340);
+		tmp = strncpy(tmp, b, 340);
 	else
-		tmp = strndupa(b, 80);
+		tmp = strncpy(tmp, b, 80);
 	ptr = audit_strsplit(tmp);
 	if (ptr) {
 		// Optionally grab the node - may or may not be included
diff --git a/src/ausearch-lol.c b/src/ausearch-lol.c
index 29d0a32..3a2e5e8 100644
--- a/src/ausearch-lol.c
+++ b/src/ausearch-lol.c
@@ -135,10 +135,12 @@ static int extract_timestamp(const char *b, event *e)
 	char *ptr, *tmp, *tnode, *ttype;
 
 	e->node = NULL;
+
+	tmp = alloca(340);
 	if (*b == 'n')
-		tmp = strndupa(b, 340);
+		tmp = strncpy(tmp, b, 340);
 	else
-		tmp = strndupa(b, 80);
+		tmp = strncpy(tmp, b, 80);
 	ptr = audit_strsplit(tmp);
 	if (ptr) {
 		// Check to see if this is the node info
-- 
2.13.1