merge: bug fixes found via coverity

This commit is contained in:
Thomas Haller 2017-12-12 11:15:55 +01:00
commit cc5ff98456
6 changed files with 17 additions and 14 deletions

View file

@ -1113,8 +1113,8 @@ show_device_info (NMDevice *device, NmCli *nmc)
(const NMMetaAbstractInfo *const*) nmc_fields_dev_show_general, (const NMMetaAbstractInfo *const*) nmc_fields_dev_show_general,
FALSE, NULL, NULL); FALSE, NULL, NULL);
row = g_new0 (NmcOutputField, _NM_META_SETTING_TYPE_NUM + 1); row = g_new0 (NmcOutputField, G_N_ELEMENTS (nmc_fields_dev_show_general));
for (i = 0; i < _NM_META_SETTING_TYPE_NUM; i++) for (i = 0; i < G_N_ELEMENTS (nmc_fields_dev_show_general); i++)
row[i].info = (const NMMetaAbstractInfo *) &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, print_required_fields (&nmc->nmc_config, NMC_OF_FLAG_MAIN_HEADER_ONLY,

View file

@ -249,7 +249,7 @@ nm_team_link_watcher_new_arp_ping (gint init_wait,
return NULL; return NULL;
} }
if (strpbrk (target_host, " \\/\t=\"\'")) { if (strpbrk (source_host, " \\/\t=\"\'")) {
g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_FAILED, g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_FAILED,
_("source-host '%s' contains invalid characters"), source_host); _("source-host '%s' contains invalid characters"), source_host);
return NULL; return NULL;

View file

@ -5155,13 +5155,16 @@ _nm_utils_team_link_watcher_from_json (json_t *json_element)
g_return_val_if_fail (json_element, NULL); g_return_val_if_fail (json_element, NULL);
json_object_foreach (json_element, j_key, j_val) { 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)); 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)); 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)); 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); val1 = json_integer_value (j_val);
else if (NM_IN_STRSET (j_key, "delay_down", "interval")) else if (NM_IN_STRSET (j_key, "delay_down", "interval"))
val2 = json_integer_value (j_val); val2 = json_integer_value (j_val);

View file

@ -1960,8 +1960,7 @@ nm_utils_resolve_conf_parse (int addr_family,
gsize i_tokens; gsize i_tokens;
tokens = nm_utils_strsplit_set (s, " \t"); tokens = nm_utils_strsplit_set (s, " \t");
nm_assert (tokens); for (i_tokens = 0; tokens && tokens[i_tokens]; i_tokens++) {
for (i_tokens = 0; tokens[i_tokens]; i_tokens++) {
gs_free char *t = g_strstrip (g_strdup (tokens[i_tokens])); gs_free char *t = g_strstrip (g_strdup (tokens[i_tokens]));
if ( _nm_utils_dns_option_validate (t, NULL, NULL, if ( _nm_utils_dns_option_validate (t, NULL, NULL,

View file

@ -1409,7 +1409,7 @@ reset_autoconnect_all (NMPolicy *self,
NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (self); NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (self);
NMSettingsConnection *const*connections = NULL; NMSettingsConnection *const*connections = NULL;
guint i; guint i;
gboolean changed; gboolean changed = FALSE;
_LOGD (LOGD_DEVICE, "re-enabling autoconnect for all connections%s%s%s", _LOGD (LOGD_DEVICE, "re-enabling autoconnect for all connections%s%s%s",
device ? " on " : "", device ? " on " : "",

View file

@ -667,6 +667,7 @@ skip:
/* There is a loop, pop the first (remaining) element from the list. /* 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. */ * This can happen for veth pairs where each peer is parent of the other end. */
item = NMP_OBJECT_CAST_LINK (links->pdata[first_idx]); item = NMP_OBJECT_CAST_LINK (links->pdata[first_idx]);
nm_assert (item);
g_hash_table_remove (unseen, GINT_TO_POINTER (item->ifindex)); g_hash_table_remove (unseen, GINT_TO_POINTER (item->ifindex));
g_ptr_array_add (result, links->pdata[first_idx]); g_ptr_array_add (result, links->pdata[first_idx]);
links->pdata[first_idx] = NULL; links->pdata[first_idx] = NULL;
@ -5320,7 +5321,7 @@ nm_platform_qdisc_to_string (const NMPlatformQdisc *qdisc, char *buf, gsize len)
void void
nm_platform_qdisc_hash_update (const NMPlatformQdisc *obj, NMHashState *h) 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, nm_hash_update_vals (h,
obj->ifindex, obj->ifindex,
obj->addr_family, obj->addr_family,
@ -5387,17 +5388,17 @@ nm_platform_tfilter_to_string (const NMPlatformTfilter *tfilter, char *buf, gsiz
void void
nm_platform_tfilter_hash_update (const NMPlatformTfilter *obj, NMHashState *h) 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, nm_hash_update_vals (h,
obj->ifindex, obj->ifindex,
obj->addr_family, obj->addr_family,
obj->handle, obj->handle,
obj->parent, obj->parent,
obj->info); obj->info);
nm_hash_update_str (h, obj->action.kind);
if (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)) 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);
} }
} }