cloud-setup: assert that NMHttpClient returns NUL terminated buffer

The behavior is documented at various places, so this assert is less
to actually assert it, but as making this condition obvious to the
reader of the code.
This commit is contained in:
Thomas Haller 2020-06-29 09:52:29 +02:00
parent e3bbd267c3
commit befd971b45
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728
2 changed files with 8 additions and 2 deletions

View file

@ -449,6 +449,8 @@ _get_config_metadata_ready_check (long response_code,
}
r_data = g_bytes_get_data (response_data, &r_len);
/* NMHttpClient guarantees that there is a trailing NUL after the data. */
nm_assert (r_data[r_len] == 0);
while (r_len > 0) {
const guint8 *p_eol;

View file

@ -246,10 +246,11 @@ _get_config_ips_list_cb (GObject *source,
if (error)
goto fips_error;
response_str = g_bytes_get_data (response, &response_len);
/* NMHttpClient guarantees that there is a trailing NUL after the data. */
nm_assert (response_str[response_len] == 0);
uri_arr = g_ptr_array_new_with_free_func (g_free);
response_str = g_bytes_get_data (response, &response_len);
while (nm_utils_parse_next_line (&response_str,
&response_len,
&line,
@ -403,6 +404,9 @@ _get_net_ifaces_list_cb (GObject *source,
}
response_str = g_bytes_get_data (response, &response_len);
/* NMHttpClient guarantees that there is a trailing NUL after the data. */
nm_assert (response_str[response_len] == 0);
ifaces_arr = g_ptr_array_new ();
gstr = g_string_new (NULL);