- Add auditd.cron (5) man page for time-based log rotation description Resolves: RHEL-77141 - Remove HALT from space_left_action - Broadcast warning to users when auditd is about to halt Resolves: RHEL-73111 - Fix TTY hostname in log messages Resolves: RHEL-79476 - permtab: remove unsupported syscalls from rules Resolves: RHEL-59560
59 lines
1.6 KiB
Diff
59 lines
1.6 KiB
Diff
diff --git a/lib/libaudit.c b/lib/libaudit.c
|
|
index de34812f0..61f9bd9da 100644
|
|
--- a/lib/libaudit.c
|
|
+++ b/lib/libaudit.c
|
|
@@ -1536,37 +1536,35 @@ static char* filter_supported_syscalls(const char* syscalls, int machine)
|
|
return NULL;
|
|
}
|
|
|
|
- // Allocate memory for the filtered syscalls string
|
|
- char* filtered_syscalls = malloc(strlen(syscalls) + 1);
|
|
- if (filtered_syscalls == NULL) {
|
|
- return NULL;
|
|
- }
|
|
- filtered_syscalls[0] = '\0'; // Initialize as empty string
|
|
-
|
|
- // Tokenize the syscalls string and filter unsupported syscalls
|
|
+ char buf[512] = "";
|
|
+ char* ptr = buf;
|
|
const char* delimiter = ",";
|
|
+
|
|
char* syscalls_copy = strdup(syscalls);
|
|
- if (syscalls_copy == NULL) {
|
|
- free(filtered_syscalls);
|
|
+ if (syscalls_copy == NULL)
|
|
return NULL;
|
|
- }
|
|
+
|
|
char* token = strtok(syscalls_copy, delimiter);
|
|
+ int first = 1; // Track if this is the first syscall being added
|
|
+
|
|
while (token != NULL) {
|
|
if (audit_name_to_syscall(token, machine) != -1) {
|
|
- strcat(filtered_syscalls, token);
|
|
- strcat(filtered_syscalls, delimiter);
|
|
+ if (!first)
|
|
+ *ptr++ = ',';
|
|
+ ptr = stpcpy(ptr, token);
|
|
+ first = 0;
|
|
}
|
|
token = strtok(NULL, delimiter);
|
|
}
|
|
+
|
|
free(syscalls_copy);
|
|
|
|
- // Remove the trailing delimiter, if present
|
|
- size_t len = strlen(filtered_syscalls);
|
|
- if (len > 0 && filtered_syscalls[len - 1] == ',') {
|
|
- filtered_syscalls[len - 1] = '\0';
|
|
+ // If no valid syscalls were found, return NULL
|
|
+ if (ptr == buf) {
|
|
+ return NULL;
|
|
}
|
|
|
|
- return filtered_syscalls;
|
|
+ return strdup(buf);
|
|
}
|
|
|
|
static int audit_add_perm_syscalls(int perm, struct audit_rule_data *rule)
|