From 90c5d1d99cea8a8a8edafb0c02f421979cf56b37 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 10 Feb 2020 15:50:38 +0100 Subject: [PATCH] shared: add debugging statement for assertion in nm_utils_parse_inaddr_bin_full() There are crashes where this assertion fails, but it's not clear how that could happen (because the input text seems a usual IPv4 address). Try to collect some more information about what failed. It's only enabled with NM_MORE_ASSERTS anyway. Related: https://bugzilla.redhat.com/show_bug.cgi?id=1797915 --- shared/nm-glib-aux/nm-shared-utils.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/shared/nm-glib-aux/nm-shared-utils.c b/shared/nm-glib-aux/nm-shared-utils.c index befde06d1f..44079dcf3a 100644 --- a/shared/nm-glib-aux/nm-shared-utils.c +++ b/shared/nm-glib-aux/nm-shared-utils.c @@ -784,7 +784,11 @@ nm_utils_parse_inaddr_bin_full (int addr_family, /* The legacy parser should accept everything that inet_pton() accepts too. Meaning, * it should strictly parse *more* formats. And of course, parse it the same way. */ - nm_assert (_parse_legacy_addr4 (text, &a)); + if (!_parse_legacy_addr4 (text, &a)) { + char buf[INET_ADDRSTRLEN]; + + g_error ("unexpected assertion failure: could parse \"%s\" as %s, but not accepted by legacy parser", text, _nm_utils_inet4_ntop (addrbin.addr4, buf)); + } nm_assert (addrbin.addr4 == a); } #endif