mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-26 08:50:33 +01:00
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.
This commit is contained in:
parent
9ee37e42e1
commit
d2f71b273e
1 changed files with 5 additions and 2 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue