Commit cc5ff984 authored by Thomas Haller's avatar Thomas Haller

merge: bug fixes found via coverity

parents f4419783 f44f21c8
......@@ -1113,8 +1113,8 @@ show_device_info (NMDevice *device, NmCli *nmc)
(const NMMetaAbstractInfo *const*) nmc_fields_dev_show_general,
FALSE, NULL, NULL);
row = g_new0 (NmcOutputField, _NM_META_SETTING_TYPE_NUM + 1);
for (i = 0; i < _NM_META_SETTING_TYPE_NUM; i++)
row = g_new0 (NmcOutputField, G_N_ELEMENTS (nmc_fields_dev_show_general));
for (i = 0; i < G_N_ELEMENTS (nmc_fields_dev_show_general); i++)
row[i].info = (const NMMetaAbstractInfo *) &nmc_fields_dev_show_general[i];
print_required_fields (&nmc->nmc_config, NMC_OF_FLAG_MAIN_HEADER_ONLY,
......
......@@ -249,7 +249,7 @@ nm_team_link_watcher_new_arp_ping (gint init_wait,
return NULL;
}
if (strpbrk (target_host, " \\/\t=\"\'")) {
if (strpbrk (source_host, " \\/\t=\"\'")) {
g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_FAILED,
_("source-host '%s' contains invalid characters"), source_host);
return NULL;
......
......@@ -5155,13 +5155,16 @@ _nm_utils_team_link_watcher_from_json (json_t *json_element)
g_return_val_if_fail (json_element, NULL);
json_object_foreach (json_element, j_key, j_val) {
if (nm_streq (j_key, "name"))
if (nm_streq (j_key, "name")) {
g_free (name);
name = strdup (json_string_value (j_val));
else if (nm_streq (j_key, "target_host"))
} else if (nm_streq (j_key, "target_host")) {
g_free (target_host);
target_host = strdup (json_string_value (j_val));
else if (nm_streq (j_key, "source_host"))
} else if (nm_streq (j_key, "source_host")) {
g_free (source_host);
source_host = strdup (json_string_value (j_val));
else if (NM_IN_STRSET (j_key, "delay_up", "init_wait"))
} else if (NM_IN_STRSET (j_key, "delay_up", "init_wait"))
val1 = json_integer_value (j_val);
else if (NM_IN_STRSET (j_key, "delay_down", "interval"))
val2 = json_integer_value (j_val);
......
......@@ -1960,8 +1960,7 @@ nm_utils_resolve_conf_parse (int addr_family,
gsize i_tokens;
tokens = nm_utils_strsplit_set (s, " \t");
nm_assert (tokens);
for (i_tokens = 0; tokens[i_tokens]; i_tokens++) {
for (i_tokens = 0; tokens && tokens[i_tokens]; i_tokens++) {
gs_free char *t = g_strstrip (g_strdup (tokens[i_tokens]));
if ( _nm_utils_dns_option_validate (t, NULL, NULL,
......
......@@ -1409,7 +1409,7 @@ reset_autoconnect_all (NMPolicy *self,
NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (self);
NMSettingsConnection *const*connections = NULL;
guint i;
gboolean changed;
gboolean changed = FALSE;
_LOGD (LOGD_DEVICE, "re-enabling autoconnect for all connections%s%s%s",
device ? " on " : "",
......
......@@ -667,6 +667,7 @@ skip:
/* There is a loop, pop the first (remaining) element from the list.
* This can happen for veth pairs where each peer is parent of the other end. */
item = NMP_OBJECT_CAST_LINK (links->pdata[first_idx]);
nm_assert (item);
g_hash_table_remove (unseen, GINT_TO_POINTER (item->ifindex));
g_ptr_array_add (result, links->pdata[first_idx]);
links->pdata[first_idx] = NULL;
......@@ -5320,7 +5321,7 @@ nm_platform_qdisc_to_string (const NMPlatformQdisc *qdisc, char *buf, gsize len)
void
nm_platform_qdisc_hash_update (const NMPlatformQdisc *obj, NMHashState *h)
{
nm_hash_update_str (h, obj->kind);
nm_hash_update_str0 (h, obj->kind);
nm_hash_update_vals (h,
obj->ifindex,
obj->addr_family,
......@@ -5387,17 +5388,17 @@ nm_platform_tfilter_to_string (const NMPlatformTfilter *tfilter, char *buf, gsiz
void
nm_platform_tfilter_hash_update (const NMPlatformTfilter *obj, NMHashState *h)
{
nm_hash_update_str (h, obj->kind);
nm_hash_update_str0 (h, obj->kind);
nm_hash_update_vals (h,
obj->ifindex,
obj->addr_family,
obj->handle,
obj->parent,
obj->info);
nm_hash_update_str (h, obj->action.kind);
if (obj->action.kind) {
nm_hash_update_str (h, obj->action.kind);
if (nm_streq (obj->action.kind, NM_PLATFORM_ACTION_KIND_SIMPLE))
nm_hash_update_str (h, obj->action.simple.sdata);
nm_hash_update_strarr (h, obj->action.simple.sdata);
}
}
......
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