Commit 9ad60ad0 authored by Thomas Haller's avatar Thomas Haller

shared: relax assertion in nm_utils_parse_inaddr()/nm_utils_parse_inaddr_prefix()

The assertion fails in nmtui's ip_route_transform_from_dest_string(),
which does not initialize the address output argument to %NULL.

There are three possibilities how the API could work:

 - assert/require the user to pass in arguments which pre-initialized
   to NULL or unset.
 - always set the output arguments, even if the function fails.
 - don't bother and leave output values untouched, if function fails.

It's not clear which approach is the best. Not to bother possibliy
leaves uninitialized values, which could be error prone. Still, do
just that.

Fixes: 0b3197a3
parent fa40fc6d
......@@ -489,8 +489,6 @@ nm_utils_parse_inaddr (int addr_family,
NMIPAddr addrbin;
char addrstr_buf[MAX (INET_ADDRSTRLEN, INET6_ADDRSTRLEN)];
nm_assert (!out_addr || !*out_addr);
if (!nm_utils_parse_inaddr_bin (addr_family, text, &addr_family, &addrbin))
return FALSE;
NM_SET_OUT (out_addr, g_strdup (inet_ntop (addr_family, &addrbin, addrstr_buf, sizeof (addrstr_buf))));
......@@ -552,8 +550,6 @@ nm_utils_parse_inaddr_prefix (int addr_family,
NMIPAddr addrbin;
char addrstr_buf[MAX (INET_ADDRSTRLEN, INET6_ADDRSTRLEN)];
nm_assert (!out_addr || !*out_addr);
if (!nm_utils_parse_inaddr_prefix_bin (addr_family, text, &addr_family, &addrbin, out_prefix))
return FALSE;
NM_SET_OUT (out_addr, g_strdup (inet_ntop (addr_family, &addrbin, addrstr_buf, sizeof (addrstr_buf))));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment