summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2022-05-09 15:33:54 +0200
committerThomas Haller <thaller@redhat.com>2022-05-11 17:06:12 +0200
commit6ebc6223033b50c660a88cb02e21697f8994b4c7 (patch)
tree5c787c285163f54f9b2babb653861f7222fc034c
parentfd4ddd8d40fade2c3b87e4e617c593afc0bffae0 (diff)
audit: handle error from audit_encode_nv_string()
audit_encode_nv_string() is documented that it might fail. Handle the error. Also, the returned string was allocated with malloc(). We must free that with free()/nm_auto_free, not g_free()/gs_free.
-rw-r--r--src/core/nm-audit-manager.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/core/nm-audit-manager.c b/src/core/nm-audit-manager.c
index dd96d834e5..4e134d1a3c 100644
--- a/src/core/nm-audit-manager.c
+++ b/src/core/nm-audit-manager.c
@@ -135,10 +135,13 @@ build_message(NMStrBuf *strbuf, AuditBackend backend, GPtrArray *fields)
#if HAVE_LIBAUDIT
if (backend == BACKEND_AUDITD) {
if (field->need_encoding) {
- gs_free char *value = NULL;
+ nm_auto_free char *value = NULL;
value = audit_encode_nv_string(field->name, str, 0);
- nm_str_buf_append(strbuf, value);
+ if (value)
+ nm_str_buf_append(strbuf, value);
+ else
+ nm_str_buf_append_printf(strbuf, "%s=???", field->name);
} else
nm_str_buf_append_printf(strbuf, "%s=%s", field->name, str);
continue;